diff --git a/agreement/models/__init__.py b/agreement/models/__init__.py index faf7817b..6502942f 100644 --- a/agreement/models/__init__.py +++ b/agreement/models/__init__.py @@ -2,6 +2,7 @@ from . import ( res_config_settings, + account, agreement, agreement_clause, agreement_section, diff --git a/agreement/models/account.py b/agreement/models/account.py new file mode 100644 index 00000000..3ff16cb3 --- /dev/null +++ b/agreement/models/account.py @@ -0,0 +1,10 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountAnalyticLine(models.Model): + _inherit = 'account.analytic.line' + + agreement_id = fields.Many2one('agreement', string='Agreement') diff --git a/agreement/models/agreement.py b/agreement/models/agreement.py index 05a3cf21..92afa39f 100644 --- a/agreement/models/agreement.py +++ b/agreement/models/agreement.py @@ -1,7 +1,7 @@ # Copyright (C) 2018 - TODAY, Pavlov Media # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models, fields, _ +from odoo import api, fields, models, _ class Agreement(models.Model): @@ -58,26 +58,20 @@ class Agreement(models.Model): "removing it." ) company_signed_date = fields.Date( - string="Company Signed Date", + string="Signed on", track_visibility='onchange', help="Date the contract was signed by Company." ) - customer_signed_date = fields.Date( - string="Customer Signed Date", + partner_signed_date = fields.Date( + string="Signed on", track_visibility='onchange', - help="Date the contract was signed by Customer." + help="Date the contract was signed by the Partner." ) - customer_term = fields.Integer( - string="Customer Term (Months)", + term = fields.Integer( + string="Term (Months)", track_visibility='onchange', - help="Number of months this agreement/contract is in effect with " - "customer." - ) - vendor_term = fields.Integer( - string="Vendor Term (Months)", - track_visibility='onchange', - help="Number of months this agreement/contract is in effect with " - "vendor." + help="Number of months this agreement/contract is in effect with the " + "partner." ) expiration_notice = fields.Integer( string="Exp. Notice (Days)", @@ -161,49 +155,48 @@ class Agreement(models.Model): string="Approved By", track_visibility='onchange' ) - currency_id = fields.Many2one( 'res.currency', string='Currency' ) - customer_id = fields.Many2one( + partner_id = fields.Many2one( 'res.partner', - string="Customer", + string="Partmer", copy=True, - help="The customer this agreement is related to (If Applicable)." + help="The customer or vendor this agreement is related to." ) - vendor_id = fields.Many2one( + company_partner_id = fields.Many2one( 'res.partner', - string="Vendor", + string="Company", copy=True, - help="The vendor this agreement is related to (If Applicable)." + default=lambda self: self.env.user.company_id.partner_id ) - customer_contact_id = fields.Many2one( + partner_contact_id = fields.Many2one( 'res.partner', - string="Customer Contact", + string="Partner Contact", copy=True, - help="The primary customer contact (If Applicable)." + help="The primary partner contact (If Applicable)." ) - customer_contact_phone = fields.Char( - related='customer_contact_id.phone', + partner_contact_phone = fields.Char( + related='partner_contact_id.phone', string="Phone" ) - customer_contact_email = fields.Char( - related='customer_contact_id.email', + partner_contact_email = fields.Char( + related='partner_contact_id.email', string="Email" ) - vendor_contact_id = fields.Many2one( + company_contact_id = fields.Many2one( 'res.partner', - string="Vendor Contact", + string="Company Contact", copy=True, - help="The primary vendor contact (If Applicable)." + help="The primary contact in the company." ) - vendor_contact_phone = fields.Char( - related='vendor_contact_id.phone', + company_contact_phone = fields.Char( + related='company_contact_id.phone', string="Phone" ) - vendor_contact_email = fields.Char( - related='vendor_contact_id.email', + company_contact_email = fields.Char( + related='company_contact_id.email', string="Email" ) agreement_type_id = fields.Many2one( @@ -243,14 +236,14 @@ class Agreement(models.Model): ) company_signed_user_id = fields.Many2one( 'res.users', - string="Company Signed By", + string="Signed By", track_visibility='onchange', help="The user at our company who authorized/signed the agreement or " "contract." ) - customer_signed_user_id = fields.Many2one( + partner_signed_user_id = fields.Many2one( 'res.partner', - string="Customer Signed By", + string="Signed By", track_visibility='onchange', help="Contact on the account that signed the agreement/contract." ) @@ -284,6 +277,12 @@ class Agreement(models.Model): string="Clauses", copy=True ) + analytic_id = fields.Many2one('account.analytic.account', + string='Analytic Account', index=True) + analytic_line_ids = fields.One2many('account.analytic.line', + 'agreement_id', + string='Revenues and Costs', + copy=False) previous_version_agreements_ids = fields.One2many( 'agreement', 'parent_agreement_id', @@ -325,11 +324,11 @@ class Agreement(models.Model): ) # compute contract_value field - @api.depends('total_customer_mrc', 'total_customer_nrc', 'customer_term') + @api.depends('total_customer_mrc', 'total_customer_nrc', 'term') def _compute_contract_value(self): for record in self: record.contract_value =\ - (record.total_customer_mrc * record.customer_term) +\ + (record.total_customer_mrc * record.term) +\ record.total_customer_nrc # compute total_company_mrc field diff --git a/agreement/models/res_partner.py b/agreement/models/res_partner.py index d8cb299b..e1523606 100644 --- a/agreement/models/res_partner.py +++ b/agreement/models/res_partner.py @@ -6,5 +6,5 @@ from odoo import models, fields class Partner(models.Model): _inherit = 'res.partner' - agreement_ids = fields.One2many('agreement', 'customer_id', + agreement_ids = fields.One2many('agreement', 'partner_id', string="Agreements") diff --git a/agreement/views/agreement.xml b/agreement/views/agreement.xml index 77e717a7..65cd9f73 100644 --- a/agreement/views/agreement.xml +++ b/agreement/views/agreement.xml @@ -8,8 +8,8 @@ - - + + @@ -40,7 +40,7 @@ + domain="[('partner_id', '=', partner_id)]"/> @@ -62,33 +62,33 @@ nolabel="1"/> - +
-
- +
-
- - - - + + + + - - - + + + @@ -97,13 +97,12 @@ - + - - + @@ -143,16 +142,16 @@ + + + + - - - - @@ -160,8 +159,20 @@ - - + + + + + + + + + + + @@ -235,7 +246,7 @@
- + oe_kanban_text_red
@@ -285,12 +296,40 @@ - + + + + agreement.graph + agreement + + + + + + + + + agreement.pivot + agreement + + + + + + + + + Agreements + agreement + form + graph,pivot + + Order Lines Search diff --git a/agreement/views/menu.xml b/agreement/views/menu.xml index 59ac12b8..d553cc53 100644 --- a/agreement/views/menu.xml +++ b/agreement/views/menu.xml @@ -67,6 +67,13 @@ parent="agreement_root" groups="agreement.group_agreement_manager"/> + +