|
|
@ -1,5 +1,6 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
"""Event Management""" |
|
|
|
import mailbox |
|
|
|
################################################################################ |
|
|
|
# |
|
|
|
# Cybrosys Technologies Pvt. Ltd. |
|
|
@ -102,6 +103,9 @@ class EventManagement(models.Model): |
|
|
|
def action_event_confirm(self): |
|
|
|
"""Button action to confirm""" |
|
|
|
self.state = "confirm" |
|
|
|
for lines in self.service_line_ids: |
|
|
|
if lines.state == 'pending': |
|
|
|
lines.is_pending = True |
|
|
|
|
|
|
|
def action_event_cancel(self): |
|
|
|
"""Button action to cancel""" |
|
|
@ -136,11 +140,18 @@ class EventManagement(models.Model): |
|
|
|
|
|
|
|
def action_event_invoice_create(self): |
|
|
|
"""Button action to create related invoice""" |
|
|
|
if self.service_line_ids.filtered(lambda x: x.state == 'pending'): |
|
|
|
raise ValidationError(_('You can create the invoice only when all ' |
|
|
|
'services is Done')) |
|
|
|
else: |
|
|
|
product_line = [] |
|
|
|
payment_list = [] |
|
|
|
related_product = self.env.ref( |
|
|
|
'event_management.catering_service_product').id |
|
|
|
product_id = self.env['product.product'].browse(related_product) |
|
|
|
for line in self.service_line_ids: |
|
|
|
if line.invoiced is False and line.state == "done": |
|
|
|
product_line.append({'product_id': line.related_product_id, |
|
|
|
product_line.append({'product_id': product_id, |
|
|
|
'price_unit': line.amount}) |
|
|
|
line.invoiced = True |
|
|
|
if len(product_line) > 0: |
|
|
@ -203,21 +214,20 @@ class EventServiceLine(models.Model): |
|
|
|
"""Model to manage the service lines of the event management""" |
|
|
|
_name = 'event.service.line' |
|
|
|
|
|
|
|
service = fields.Selection([('', '')], string="Services", |
|
|
|
required=True) |
|
|
|
service_id = fields.Many2one('event.services', string="Services") |
|
|
|
event_id = fields.Many2one('event.management', string="Event") |
|
|
|
date_from = fields.Datetime(string="Date from", required=True) |
|
|
|
date_to = fields.Datetime(string="Date to", required=True) |
|
|
|
amount = fields.Float(string="Amount", readonly=True) |
|
|
|
amount = fields.Float(string="Amount") |
|
|
|
state = fields.Selection([('done', 'Done'), ('pending', 'Pending')], |
|
|
|
string="State", default="pending", |
|
|
|
readonly=True) |
|
|
|
string="State") |
|
|
|
currency_id = fields.Many2one('res.currency', readonly=True, |
|
|
|
default=lambda self: |
|
|
|
self.env.user.company_id.currency_id) |
|
|
|
invoiced = fields.Boolean(string="Invoiced", readonly=True) |
|
|
|
related_product_id = fields.Many2one('product.product', |
|
|
|
string="Related Product") |
|
|
|
is_pending = fields.Boolean(string="Pending") |
|
|
|
|
|
|
|
_sql_constraints = [('event_supplier_unique', 'unique(event_id, service)', |
|
|
|
'Duplication Of Service In The Service Lines ' |
|
|
@ -230,7 +240,13 @@ class EventServiceLine(models.Model): |
|
|
|
raise ValidationError(_('"Date to" cannot be set before ' |
|
|
|
'"Date from".\n\n' |
|
|
|
'Check the "Date from" and "Date to" ' |
|
|
|
'of the "%s" service' % rec.service)) |
|
|
|
'of the "%s" service' % rec.service_id)) |
|
|
|
|
|
|
|
|
|
|
|
class EventService(models.Model): |
|
|
|
_name = 'event.services' |
|
|
|
|
|
|
|
name = fields.Char(string='Services') |
|
|
|
|
|
|
|
|
|
|
|
class EventManagementType(models.Model): |
|
|
|