From 1e1877e56f7d9637162ed79507b375994fb27622 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 16 Oct 2018 16:03:53 -0500 Subject: [PATCH] [IMP Views --- agreement/__manifest__.py | 67 +++++------ agreement/data/ir_sequence.xml | 13 +++ agreement/models/agreement.py | 69 +++--------- agreement/models/res_partner.py | 8 +- agreement/views/agreement.xml | 125 ++++++++++++--------- agreement/views/agreement_increasetype.xml | 13 ++- agreement/views/agreement_renewaltype.xml | 9 +- agreement/views/agreement_subtype.xml | 14 +-- agreement/views/agreement_type.xml | 9 +- agreement/views/res_partner.xml | 4 +- 10 files changed, 158 insertions(+), 173 deletions(-) create mode 100644 agreement/data/ir_sequence.xml diff --git a/agreement/__manifest__.py b/agreement/__manifest__.py index 0d2c31a5..b3251a3b 100644 --- a/agreement/__manifest__.py +++ b/agreement/__manifest__.py @@ -2,40 +2,41 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - "name": "Agreements", - "summary": "Manage Agreements, LOI and Contracts", - "author": "Pavlov Media, " - "Open Source Integrators, " - "Odoo Community Association (OCA)", - "website": "https://github.com/OCA/contract", - "category": "Partner", - "license": "AGPL-3", - "version": "11.0.0.0.1", - "depends": [ - "account", - "contacts", - "mail", - "product", - "sale_management", + 'name': 'Agreements', + 'summary': 'Manage Agreements, LOI and Contracts', + 'author': 'Pavlov Media, ' + 'Open Source Integrators, ' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/contract', + 'category': 'Partner', + 'license': 'AGPL-3', + 'version': '11.0.0.0.1', + 'depends': [ + 'account', + 'contacts', + 'mail', + 'product', + 'sale_management', ], - "data": [ - "data/module_category.xml", - "security/res_groups.xml", - "security/ir.model.access.csv", + 'data': [ + 'data/ir_sequence.xml', + 'data/module_category.xml', + 'security/res_groups.xml', + 'security/ir.model.access.csv', 'views/res_config_settings.xml', - "views/reports.xml", - "views/agreement.xml", - "views/agreement_clause.xml", - "views/agreement_section.xml", - "views/agreement_stages.xml", - "views/agreement_type.xml", - "views/agreement_subtype.xml", - "views/agreement_renewaltype.xml", - "views/agreement_increasetype.xml", - "views/res_partner.xml", - "views/menu.xml", + 'views/reports.xml', + 'views/agreement.xml', + 'views/agreement_clause.xml', + 'views/agreement_section.xml', + 'views/agreement_stages.xml', + 'views/agreement_type.xml', + 'views/agreement_subtype.xml', + 'views/agreement_renewaltype.xml', + 'views/agreement_increasetype.xml', + 'views/res_partner.xml', + 'views/menu.xml', ], - "application": True, - "development_status": "Beta", - "maintainers": "max3903", + 'application': True, + 'development_status': 'Beta', + 'maintainers': 'max3903', } diff --git a/agreement/data/ir_sequence.xml b/agreement/data/ir_sequence.xml new file mode 100644 index 00000000..d2104c55 --- /dev/null +++ b/agreement/data/ir_sequence.xml @@ -0,0 +1,13 @@ + + + + + + Agreements + agreement + AG + 3 + + + + diff --git a/agreement/models/agreement.py b/agreement/models/agreement.py index a9b3eb24..f96a670d 100644 --- a/agreement/models/agreement.py +++ b/agreement/models/agreement.py @@ -1,10 +1,9 @@ # Copyright (C) 2018 - TODAY, Pavlov Media # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api +from odoo import api, models, fields, _ -# Main Agreement Records Model class Agreement(models.Model): _name = 'agreement' _inherit = ['mail.thread'] @@ -99,8 +98,10 @@ class Agreement(models.Model): help="Total value of the contract over ther entire term.", store=True ) - contract_id = fields.Char( - string="ID", + reference = fields.Char( + string="Reference", + required=True, + default=lambda self: _('New'), track_visibility='onchange', help="ID used for internal contract tracking.") total_company_mrc = fields.Monetary( @@ -139,54 +140,6 @@ class Agreement(models.Model): track_visibility='onchange', help="Date that the contract was terminated." ) - customer_address = fields.Char( - related='customer_id.contact_address', - string="Address" - ) - customer_street = fields.Char( - related='customer_id.street', - string="Street" - ) - customer_street2 = fields.Char( - related='customer_id.street2', - string="Street 2" - ) - customer_city = fields.Char( - related='customer_id.city', - string="City" - ) - customer_state_id = fields.Many2one( - related='customer_id.state_id', - string="State" - ) - customer_zip = fields.Char( - related='customer_id.zip', - string="Zip" - ) - vendor_address = fields.Char( - related='vendor_id.contact_address', - string="Address" - ) - vendor_street = fields.Char( - related='vendor_id.street', - string="Street" - ) - vendor_street2 = fields.Char( - related='vendor_id.street2', - string="Street 2" - ) - vendor_city = fields.Char( - related='vendor_id.city', - string="City" - ) - vendor_state_id = fields.Many2one( - related='vendor_id.state_id', - string="State" - ) - vendor_zip = fields.Char( - related='vendor_id.zip', - string="Zip" - ) reviewed_date = fields.Date( string="Reviewed Date", track_visibility='onchange' @@ -236,7 +189,6 @@ class Agreement(models.Model): related='customer_contact_id.email', string="Email" ) - vendor_contact_id = fields.Many2one( 'res.partner', string="Vendor Contact", @@ -264,6 +216,9 @@ class Agreement(models.Model): help="Select the sub-type of this agreement. Sub-Types are related to " "agreement types." ) + product_ids = fields.Many2many( + 'product.template', + string="Products & Services") sale_order_id = fields.Many2one( 'sale.order', string="Sales Order", @@ -309,7 +264,6 @@ class Agreement(models.Model): track_visibility='onchange', help="Describes what happens after the contract expires." ) - order_lines_services_ids = fields.One2many( related='sale_order_id.order_line', string="Service Order Lines", @@ -428,6 +382,13 @@ class Agreement(models.Model): 'view_type': 'form', 'res_id': res.id} + @api.model + def create(self, vals): + if vals.get('reference', _('New')) == _('New'): + vals['reference'] = \ + self.env['ir.sequence'].next_by_code('agreement') or _('New') + return super(Agreement, self).create(vals) + # Increments the revision on each save action @api.multi def write(self, vals): diff --git a/agreement/models/res_partner.py b/agreement/models/res_partner.py index 61c30d0c..d8cb299b 100644 --- a/agreement/models/res_partner.py +++ b/agreement/models/res_partner.py @@ -6,9 +6,5 @@ from odoo import models, fields class Partner(models.Model): _inherit = 'res.partner' - - agreements_ids = fields.One2many( - 'agreement', - 'name', - string="Agreements" - ) + agreement_ids = fields.One2many('agreement', 'customer_id', + string="Agreements") diff --git a/agreement/views/agreement.xml b/agreement/views/agreement.xml index dc753771..77e717a7 100644 --- a/agreement/views/agreement.xml +++ b/agreement/views/agreement.xml @@ -36,30 +36,34 @@ - - - - - - - - + + + + + + + + + + + + + - + + required="True" + nolabel="1"/> - + + string="Customer">
+ string="Vendor">
- - + + @@ -114,16 +119,20 @@
- - + + - - + + @@ -133,32 +142,39 @@ - - - - - - - + + + + + + + + + + + - - - - - - - - - + - + - - + + + + + + + + + + + + + - + @@ -167,7 +183,7 @@ - + @@ -176,17 +192,16 @@ - +

This section is a place where financial records will show the current performance of this agreement.

Perhaps include invoices with total vs costs?

- - - - - - + +
+

Reviewed by on .

+

Approved by on .

+