From 2789dfbb8e7fb5b2139570c333db2ecad7171597 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Fri, 11 Jan 2019 17:59:59 -0600 Subject: [PATCH] [IMP] agreement_sale --- agreement_sale/__init__.py | 3 ++- agreement_sale/__manifest__.py | 7 ++++--- agreement_sale/models/__init__.py | 4 +++- agreement_sale/models/agreement.py | 4 ++-- agreement_sale/models/product.py | 13 +++++++++++++ agreement_sale/models/sale_order.py | 11 ++++------- agreement_sale/readme/ROADMAP.rst | 2 +- agreement_sale/views/agreement.xml | 6 +++--- agreement_sale/views/product.xml | 25 +++++++++++++++++++++++++ agreement_sale/views/sale_order.xml | 6 +++--- 10 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 agreement_sale/models/product.py create mode 100644 agreement_sale/views/product.xml diff --git a/agreement_sale/__init__.py b/agreement_sale/__init__.py index 7fab5e1c..b634044c 100644 --- a/agreement_sale/__init__.py +++ b/agreement_sale/__init__.py @@ -1,3 +1,4 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright (C) 2019 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models diff --git a/agreement_sale/__manifest__.py b/agreement_sale/__manifest__.py index bb7b0ac2..d72ef59e 100644 --- a/agreement_sale/__manifest__.py +++ b/agreement_sale/__manifest__.py @@ -1,5 +1,5 @@ -# Copyright (C) 2018 - TODAY, Open Source Integrators -# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright (C) 2019 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Agreement - Sale', @@ -15,7 +15,8 @@ ], 'data': [ 'views/agreement.xml', - 'views/sale_order.xml' + 'views/product.xml', + 'views/sale_order.xml', ], 'installable': True, 'development_status': 'Beta', diff --git a/agreement_sale/models/__init__.py b/agreement_sale/models/__init__.py index 87270557..f136a926 100644 --- a/agreement_sale/models/__init__.py +++ b/agreement_sale/models/__init__.py @@ -1,6 +1,8 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright (C) 2019 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import ( sale_order, agreement, + product, ) diff --git a/agreement_sale/models/agreement.py b/agreement_sale/models/agreement.py index 157fc158..85095c56 100644 --- a/agreement_sale/models/agreement.py +++ b/agreement_sale/models/agreement.py @@ -1,5 +1,5 @@ -# Copyright (C) 2018 - TODAY, Open Source Integrators -# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright (C) 2019 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models diff --git a/agreement_sale/models/product.py b/agreement_sale/models/product.py new file mode 100644 index 00000000..59d7c8f0 --- /dev/null +++ b/agreement_sale/models/product.py @@ -0,0 +1,13 @@ +# Copyright (C) 2019 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_serviceprofile = fields.Boolean( + string="Create a Service Profile", + help="""If True, this product will create a service profile on the + agreement when the sales order is confirmed.""") diff --git a/agreement_sale/models/sale_order.py b/agreement_sale/models/sale_order.py index 1d1e64ac..34490442 100644 --- a/agreement_sale/models/sale_order.py +++ b/agreement_sale/models/sale_order.py @@ -1,5 +1,5 @@ -# Copyright (C) 2018 - TODAY, Open Source Integrators -# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +# Copyright (C) 2019 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models @@ -37,11 +37,8 @@ class SaleOrder(models.Model): 'sale_line_id': line.id, 'uom_id': line.product_uom.id }) - # If the product sold has a BOM, create a service profile - bom = self.env['mrp.bom'].search( - [('product_tmpl_id', '=', - line.product_id.product_tmpl_id.id)]) - if bom: + # If the product is a service profile, create one + if line.product_id.product_tmpl_id.is_serviceprofile: self.env['agreement.serviceprofile'].create({ 'name': line.name, 'agreement_id': order.agreement_id.id, diff --git a/agreement_sale/readme/ROADMAP.rst b/agreement_sale/readme/ROADMAP.rst index 294d0acd..c6d54c4f 100644 --- a/agreement_sale/readme/ROADMAP.rst +++ b/agreement_sale/readme/ROADMAP.rst @@ -1 +1 @@ -The roadmap is documented on https://github.com/OCA/contract/issues. \ No newline at end of file +The roadmap is documented on https://github.com/OCA/contract/issues. diff --git a/agreement_sale/views/agreement.xml b/agreement_sale/views/agreement.xml index cf2faf8a..cb73ad6b 100644 --- a/agreement_sale/views/agreement.xml +++ b/agreement_sale/views/agreement.xml @@ -1,10 +1,10 @@ - + - + agreement.form.view agreement diff --git a/agreement_sale/views/product.xml b/agreement_sale/views/product.xml new file mode 100644 index 00000000..fbab53e8 --- /dev/null +++ b/agreement_sale/views/product.xml @@ -0,0 +1,25 @@ + + + + + + + product.template.form.view + product.template + + + + + + + + + + + + + + + + diff --git a/agreement_sale/views/sale_order.xml b/agreement_sale/views/sale_order.xml index f598f3b3..eedba901 100644 --- a/agreement_sale/views/sale_order.xml +++ b/agreement_sale/views/sale_order.xml @@ -1,10 +1,10 @@ - + - + sale.order.agreement.form.view sale.order