Browse Source

Oct 7 : [FIX] Bug Fixed 'event_management'

pull/295/head
AjmalCybro 2 years ago
parent
commit
c338ec0657
  1. 2
      event_management/__manifest__.py
  2. 26
      event_management/data/event_management.xml
  3. 146
      event_management/models/event_management.py
  4. 1
      event_management/security/ir.model.access.csv
  5. BIN
      event_management/static/img/catering_product-image.jpeg
  6. 23
      event_management/views/event_management_view.xml

2
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",

26
event_management/data/event_management.xml

@ -4,33 +4,45 @@
<record id="event_type1" model="event.management.type">
<field name="name">Wedding</field>
<field name="image" type="base64" file="event_management/static/img/event_type_image1.jpg"/>
<field name="image" type="base64"
file="event_management/static/img/event_type_image1.jpg"/>
</record>
<record id="event_type2" model="event.management.type">
<field name="name">Birthday</field>
<field name="image" type="base64" file="event_management/static/img/event_type_image2.jpeg"/>
<field name="image" type="base64"
file="event_management/static/img/event_type_image2.jpeg"/>
</record>
<record id="event_type3" model="event.management.type">
<field name="name">Family Events</field>
<field name="image" type="base64" file="event_management/static/img/event_type_image3.jpeg"/>
<field name="image" type="base64"
file="event_management/static/img/event_type_image3.jpeg"/>
</record>
<record id="event_type4" model="event.management.type">
<field name="name">Press Conference</field>
<field name="image" type="base64" file="event_management/static/img/event_type_image4.jpeg"/>
<field name="image" type="base64"
file="event_management/static/img/event_type_image4.jpeg"/>
</record>
<record id="event_type5" model="event.management.type">
<field name="name">Seminars</field>
<field name="image" type="base64" file="event_management/static/img/event_type_image5.jpeg"/>
<field name="image" type="base64"
file="event_management/static/img/event_type_image5.jpeg"/>
</record>
<record id="event_type6" model="event.management.type">
<field name="name">Conferences</field>
<field name="image" type="base64" file="event_management/static/img/event_type_image6.jpeg"/>
<field name="image" type="base64"
file="event_management/static/img/event_type_image6.jpeg"/>
</record>
<record model="product.product" id="catering_service_product">
<field name="name">Event Service</field>
<field name="type">service</field>
<field name="image_1920" type="base64"
file="event_management/static/img/catering_product-image.jpeg"/>
</record>
<record id="sequence_event_order" model="ir.sequence">
<field name="name">Event Order</field>
<field name="code">event.order.sequence</field>
<field name="suffix"> %(day)s/%(month)s/%(year)s</field>
<field name="suffix">%(day)s/%(month)s/%(year)s</field>
<field name="prefix">EVE-</field>
<field name="number_increment">1</field>
<field name="padding">2</field>

146
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):

1
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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
3 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
4 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
5 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
6 access_event_services event.services event_management.model_event_services event_management.group_event_manager 1 1 1 1

BIN
event_management/static/img/catering_product-image.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

23
event_management/views/event_management_view.xml

@ -91,27 +91,18 @@
</group>
<notebook>
<page string="Service Lines">
<field name="service_line_ids" mode="tree" attrs="{'readonly': [('state', 'not in', ['draft'])]}">
<form string="Service Lines Form">
<group>
<group>
<field name="service"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="amount"/>
</group>
</group>
</form>
<field name="service_line_ids" mode="tree" attrs="{'readonly': [('state', 'not in', ['draft', 'confirm'])]}">
<tree string="Service Lines Tree" editable="bottom">
<field name="service" class="oe_inline"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="state" readonly="1"/>
<field name="service_id" class="oe_inline" attrs="{'readonly': [('is_pending', '=', True)]}"/>
<field name="date_from" attrs="{'readonly': [('is_pending', '=', True)]}"/>
<field name="date_to" attrs="{'readonly': [('is_pending', '=', True)]}"/>
<field name="state" class="oe_inline"/>
<field name="is_pending" invisible="1"/>
<field name="invoiced" readonly="1"/>
<field name="currency_id" invisible="1"/>
<field name="related_product_id" invisible="1"/>
<field name="invoiced" invisible="1"/>
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}" />
</tree>
</field>
<group class="oe_subtotal_footer oe_right" colspan="2" name="event_total">

Loading…
Cancel
Save