diff --git a/event_management/__manifest__.py b/event_management/__manifest__.py index 444e3d94f..1acdd2ec2 100644 --- a/event_management/__manifest__.py +++ b/event_management/__manifest__.py @@ -21,7 +21,7 @@ ################################################################################### { 'name': 'Event Management', - 'version': '16.0.1.0.0', + 'version': '16.0.2.0.0', 'summary': """Core Module for Managing Different Types Of Events.""", 'description': """Core Module for Managing Different Types Of Events""", "category": "Industry", diff --git a/event_management/data/event_management.xml b/event_management/data/event_management.xml index f9edf8ad5..cdc0f9dcf 100644 --- a/event_management/data/event_management.xml +++ b/event_management/data/event_management.xml @@ -4,33 +4,45 @@ Wedding - + Birthday - + Family Events - + Press Conference - + Seminars - + Conferences - + + + + Event Service + service + Event Order event.order.sequence - %(day)s/%(month)s/%(year)s + %(day)s/%(month)s/%(year)s EVE- 1 2 diff --git a/event_management/models/event_management.py b/event_management/models/event_management.py index f7e0c4e00..1ca5f5942 100644 --- a/event_management/models/event_management.py +++ b/event_management/models/event_management.py @@ -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,88 +140,94 @@ class EventManagement(models.Model): def action_event_invoice_create(self): """Button action to create related invoice""" - product_line = [] - payment_list = [] - 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, - 'price_unit': line.amount}) - line.invoiced = True - if len(product_line) > 0: - invoice = self.env['account.move'] - move_type = 'out_invoice' - invoice = invoice.with_context(default_move_type=move_type) - journal_id = invoice._compute_journal_id() - company_id = self.env.user.company_id.id - inv_obj = self.env['account.move'] - partner = self.partner_id - for records in product_line: - product_id = records['product_id'] - price_unit = records['price_unit'] - if product_id.property_account_income_id.id: - income_account = product_id.property_account_income_id.id - elif product_id.categ_id.property_account_income_categ_id.id: - income_account = product_id.categ_id.property_account_income_categ_id.id - else: - raise UserError( - _('Please define income account for' - ' this product: "%s" (id:%d).') % ( - product_id.name, product_id.id)) + 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': product_id, + 'price_unit': line.amount}) + line.invoiced = True + if len(product_line) > 0: + invoice = self.env['account.move'] + move_type = 'out_invoice' + invoice = invoice.with_context(default_move_type=move_type) + journal_id = invoice._compute_journal_id() + company_id = self.env.user.company_id.id + inv_obj = self.env['account.move'] + partner = self.partner_id + for records in product_line: + product_id = records['product_id'] + price_unit = records['price_unit'] + if product_id.property_account_income_id.id: + income_account = product_id.property_account_income_id.id + elif product_id.categ_id.property_account_income_categ_id.id: + income_account = product_id.categ_id.property_account_income_categ_id.id + else: + raise UserError( + _('Please define income account for' + ' this product: "%s" (id:%d).') % ( + product_id.name, product_id.id)) - inv_line_data = { - 'name': self.name, - 'account_id': income_account, - 'price_unit': price_unit, - 'quantity': 1, - 'product_id': product_id.id, - 'product_uom_id': product_id.uom_id.id, + inv_line_data = { + 'name': self.name, + 'account_id': income_account, + 'price_unit': price_unit, + 'quantity': 1, + 'product_id': product_id.id, + 'product_uom_id': product_id.uom_id.id, + } + payment_list.append((0, 0, inv_line_data)) + inv_data = { + 'move_type': move_type, + 'ref': self.name, + 'bank_partner_id': partner.property_account_payable_id.id, + 'partner_id': partner.id, + 'payment_reference': self.name, + 'company_id': company_id, + 'invoice_line_ids': payment_list, + } + inv_id = inv_obj.create(inv_data) + result = { + 'view_type': 'form', + 'res_model': 'account.move', + 'res_id': inv_id.id, + 'view_id': False, + 'view_mode': 'form', + 'type': 'ir.actions.act_window' } - payment_list.append((0, 0, inv_line_data)) - inv_data = { - 'move_type': move_type, - 'ref': self.name, - 'bank_partner_id': partner.property_account_payable_id.id, - 'partner_id': partner.id, - 'payment_reference': self.name, - 'company_id': company_id, - 'invoice_line_ids': payment_list, - } - inv_id = inv_obj.create(inv_data) - result = { - 'view_type': 'form', - 'res_model': 'account.move', - 'res_id': inv_id.id, - 'view_id': False, - 'view_mode': 'form', - 'type': 'ir.actions.act_window' - } - self.state = "invoice" - all_invoice_ids = self.invoice_ids.ids - all_invoice_ids.append(inv_id.id) - self.update({'invoice_ids': all_invoice_ids, - 'invoice_count': self.invoice_count + 1}) - return result + self.state = "invoice" + all_invoice_ids = self.invoice_ids.ids + all_invoice_ids.append(inv_id.id) + self.update({'invoice_ids': all_invoice_ids, + 'invoice_count': self.invoice_count + 1}) + return result 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): diff --git a/event_management/security/ir.model.access.csv b/event_management/security/ir.model.access.csv index 2a1b16c49..f6712e899 100644 --- a/event_management/security/ir.model.access.csv +++ b/event_management/security/ir.model.access.csv @@ -3,3 +3,4 @@ access_event_management_event_manager,event.management.event.manager,event_manag access_event_service_line_event_manager,event.service.line.event.manager,event_management.model_event_service_line,event_management.group_event_manager,1,1,1,1 access_event_management_type_event_manager,event.management.type.event.manager,event_management.model_event_management_type,event_management.group_event_manager,1,1,1,1 access_event_management_wizard_event_manager,event.management.wizard.event.manager,event_management.model_event_management_wizard,event_management.group_event_manager,1,1,1,1 +access_event_services,event.services,event_management.model_event_services,event_management.group_event_manager,1,1,1,1 diff --git a/event_management/static/img/catering_product-image.jpeg b/event_management/static/img/catering_product-image.jpeg new file mode 100644 index 000000000..8563d90ea Binary files /dev/null and b/event_management/static/img/catering_product-image.jpeg differ diff --git a/event_management/views/event_management_view.xml b/event_management/views/event_management_view.xml index bc5503680..158b08515 100644 --- a/event_management/views/event_management_view.xml +++ b/event_management/views/event_management_view.xml @@ -91,27 +91,18 @@ - -
- - - - - - - - -
+ - - - - + + + + + - +