From a5353ac1d15d34ca84554ada136f167a79cb1580 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 5 Sep 2019 12:17:51 -0500 Subject: [PATCH] [FIX] agreement_serviceprofile: Github Issue #370 --- agreement_serviceprofile/__manifest__.py | 3 ++- agreement_serviceprofile/models/__init__.py | 1 + .../models/agreement_serviceprofile.py | 3 ++- agreement_serviceprofile/models/product.py | 18 ++++++++++++++ agreement_serviceprofile/views/product.xml | 24 +++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 agreement_serviceprofile/models/product.py create mode 100644 agreement_serviceprofile/views/product.xml diff --git a/agreement_serviceprofile/__manifest__.py b/agreement_serviceprofile/__manifest__.py index 7813d237..9deff235 100644 --- a/agreement_serviceprofile/__manifest__.py +++ b/agreement_serviceprofile/__manifest__.py @@ -15,8 +15,9 @@ 'data': [ 'data/serviceprofile_stage.xml', 'security/ir.model.access.csv', + 'views/product.xml', 'views/agreement_serviceprofile.xml', - 'views/agreement.xml' + 'views/agreement.xml', ], 'development_status': 'Beta', 'maintainers': [ diff --git a/agreement_serviceprofile/models/__init__.py b/agreement_serviceprofile/models/__init__.py index b0ff00e0..ee547834 100644 --- a/agreement_serviceprofile/models/__init__.py +++ b/agreement_serviceprofile/models/__init__.py @@ -1,3 +1,4 @@ from . import agreement_serviceprofile from . import agreement from . import agreement_stage +from . import product diff --git a/agreement_serviceprofile/models/agreement_serviceprofile.py b/agreement_serviceprofile/models/agreement_serviceprofile.py index 0e5ac452..c152e4de 100644 --- a/agreement_serviceprofile/models/agreement_serviceprofile.py +++ b/agreement_serviceprofile/models/agreement_serviceprofile.py @@ -26,7 +26,8 @@ class AgreementServiceProfile(models.Model): notes = fields.Text(string="Notes") product_id = fields.Many2one('product.template', 'Service Product', - domain="[('type', '=', 'service')]", + domain="[('is_serviceprofile', '=', True), " + "('type', '=', 'service')]", required=True) partner_id = fields.Many2one(related='agreement_id.partner_id', string='Partner') diff --git a/agreement_serviceprofile/models/product.py b/agreement_serviceprofile/models/product.py new file mode 100644 index 00000000..afde8de0 --- /dev/null +++ b/agreement_serviceprofile/models/product.py @@ -0,0 +1,18 @@ +# 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 + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_serviceprofile = fields.Boolean( + string="Create Service Profiles", + help="""If True, this product will create a service profile on the + agreement when the sales order is confirmed.""") + + @api.onchange('is_serviceprofile') + def onchange_type(self): + if self.is_serviceprofile: + self.type = 'service' diff --git a/agreement_serviceprofile/views/product.xml b/agreement_serviceprofile/views/product.xml new file mode 100644 index 00000000..d5b0571d --- /dev/null +++ b/agreement_serviceprofile/views/product.xml @@ -0,0 +1,24 @@ + + + + + + product.template.form.view + product.template + + + + + + + + + + + + + + + +