From 5e2e4bc9060fb8e88f51e5aaf439ed0b32ed5586 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 27 Sep 2019 09:41:19 +0200 Subject: [PATCH] [IMP] move some notions from agreement_legal to agreement we move the is_template field definition and the agreement.type model from the agreement_legal module to the agreement module. The fields are not displayed by default, unless the feature is enabled through a technical feature group, this is configurable in the agreement_sale module (because agreement in itself has no UI, and agreement_legal enables the feature by default) --- agreement/__manifest__.py | 1 + agreement/models/__init__.py | 1 + agreement/models/agreement.py | 14 +++++- agreement/models/agreement_type.py | 12 +++++ agreement/readme/CONTRIBUTORS.rst | 1 + agreement/readme/DESCRIPTION.rst | 6 +++ agreement/security/agreement_security.xml | 9 ++++ agreement/views/agreement.xml | 6 ++- agreement/views/agreement_type.xml | 54 +++++++++++++++++++++++ 9 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 agreement/models/agreement_type.py create mode 100644 agreement/views/agreement_type.xml diff --git a/agreement/__manifest__.py b/agreement/__manifest__.py index 96638f92..f340688f 100644 --- a/agreement/__manifest__.py +++ b/agreement/__manifest__.py @@ -16,6 +16,7 @@ 'security/ir.model.access.csv', 'security/agreement_security.xml', 'views/agreement.xml', + 'views/agreement_type.xml', ], 'demo': ['demo/demo.xml'], 'development_status': 'Beta', diff --git a/agreement/models/__init__.py b/agreement/models/__init__.py index 51f4021f..8fc631aa 100644 --- a/agreement/models/__init__.py +++ b/agreement/models/__init__.py @@ -1 +1,2 @@ from . import agreement +from . import agreement_type diff --git a/agreement/models/agreement.py b/agreement/models/agreement.py index b09b4dbc..68bb8e17 100644 --- a/agreement/models/agreement.py +++ b/agreement/models/agreement.py @@ -12,11 +12,23 @@ class Agreement(models.Model): code = fields.Char(required=True, copy=False) name = fields.Char(required=True) partner_id = fields.Many2one( - 'res.partner', string='Partner', ondelete='restrict', required=True, + 'res.partner', string='Partner', ondelete='restrict', domain=[('parent_id', '=', False)]) company_id = fields.Many2one( 'res.company', string='Company', default=lambda self: self.env['res.company']._company_default_get()) + is_template = fields.Boolean( + string="Is a Template?", + default=False, + copy=False, + help="Set if the agreement is a template. " + "Template agreements don't require a partner." + ) + agreement_type_id = fields.Many2one( + 'agreement.type', + string="Agreement Type", + help="Select the type of agreement", + ) active = fields.Boolean(default=True) signature_date = fields.Date() start_date = fields.Date() diff --git a/agreement/models/agreement_type.py b/agreement/models/agreement_type.py new file mode 100644 index 00000000..a35a6482 --- /dev/null +++ b/agreement/models/agreement_type.py @@ -0,0 +1,12 @@ +# Copyright (C) 2018 - TODAY, Pavlov Media +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AgreementType(models.Model): + _name = "agreement.type" + _description = "Agreement Types" + + name = fields.Char(string="Name", required=True) + active = fields.Boolean(default=True) diff --git a/agreement/readme/CONTRIBUTORS.rst b/agreement/readme/CONTRIBUTORS.rst index bc3bbf22..05342b33 100644 --- a/agreement/readme/CONTRIBUTORS.rst +++ b/agreement/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Alexis de Lattre * Yves Goldberg +* Alexandre Fayolle diff --git a/agreement/readme/DESCRIPTION.rst b/agreement/readme/DESCRIPTION.rst index c58e0465..24b6ee5a 100644 --- a/agreement/readme/DESCRIPTION.rst +++ b/agreement/readme/DESCRIPTION.rst @@ -6,3 +6,9 @@ This module adds an *Agreement* object with the following properties: * signature date. * start date. * end date. + +Optionally, you can also enable using: +* agreement types +* a flag to set an agreement as a template agreement + +(Install agreement_sale to get the configuration settings for these). diff --git a/agreement/security/agreement_security.xml b/agreement/security/agreement_security.xml index d645ef6d..9784e6b7 100644 --- a/agreement/security/agreement_security.xml +++ b/agreement/security/agreement_security.xml @@ -13,5 +13,14 @@ ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + Use agreement type + + + + + Use agreement template + + diff --git a/agreement/views/agreement.xml b/agreement/views/agreement.xml index 15f284ce..8754247c 100644 --- a/agreement/views/agreement.xml +++ b/agreement/views/agreement.xml @@ -21,7 +21,11 @@ - + + + diff --git a/agreement/views/agreement_type.xml b/agreement/views/agreement_type.xml new file mode 100644 index 00000000..1ca06a47 --- /dev/null +++ b/agreement/views/agreement_type.xml @@ -0,0 +1,54 @@ + + + + + Agreement Type List + agreement.type + + + + + + + + + + Agreement Type Form + agreement.type + +
+
+ +
+ +
+
+
+
+
+
+ + + agreement.type.search + agreement.type + + + + + + + + + + + Agreement Types + agreement.type + tree,form + +