From b5ac8af44725a73a209a550bbc2d266e063aa31c 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_sale/__manifest__.py | 2 + agreement_sale/models/__init__.py | 1 + agreement_sale/models/res_config_settings.py | 14 ++++++ agreement_sale/models/sale.py | 6 +++ agreement_sale/security/ir.model.access.csv | 2 + agreement_sale/views/agreement.xml | 4 +- agreement_sale/views/res_config_settings.xml | 48 ++++++++++++++++++++ agreement_sale/views/sale_order.xml | 19 ++++++++ 8 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 agreement_sale/models/res_config_settings.py create mode 100644 agreement_sale/views/res_config_settings.xml create mode 100644 agreement_sale/views/sale_order.xml diff --git a/agreement_sale/__manifest__.py b/agreement_sale/__manifest__.py index 29ef5bc1..80c8c166 100644 --- a/agreement_sale/__manifest__.py +++ b/agreement_sale/__manifest__.py @@ -17,6 +17,8 @@ 'data': [ 'security/ir.model.access.csv', 'views/agreement.xml', + 'views/sale_order.xml', + 'views/res_config_settings.xml', ], 'development_status': 'Beta', 'maintainers': [ diff --git a/agreement_sale/models/__init__.py b/agreement_sale/models/__init__.py index 8a0dc04e..534c392d 100644 --- a/agreement_sale/models/__init__.py +++ b/agreement_sale/models/__init__.py @@ -1 +1,2 @@ from . import sale +from . import res_config_settings diff --git a/agreement_sale/models/res_config_settings.py b/agreement_sale/models/res_config_settings.py new file mode 100644 index 00000000..167bc9c4 --- /dev/null +++ b/agreement_sale/models/res_config_settings.py @@ -0,0 +1,14 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + group_use_agreement_type = fields.Boolean( + 'Use agreement types', + implied_group='agreement.group_use_agreement_type' + ) + group_use_agreement_template = fields.Boolean( + 'Use agreement template', + implied_group='agreement.group_use_agreement_template' + ) diff --git a/agreement_sale/models/sale.py b/agreement_sale/models/sale.py index 556db2f7..bf97d9de 100644 --- a/agreement_sale/models/sale.py +++ b/agreement_sale/models/sale.py @@ -12,3 +12,9 @@ class SaleOrder(models.Model): comodel_name='agreement', string='Agreement', ondelete='restrict', track_visibility='onchange', readonly=True, copy=False, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}) + + agreement_type_id = fields.Many2one( + comodel_name="agreement.type", string="Agreement Type", + ondelete="restrict", + track_visibility='onchange', readonly=True, copy=True, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}) diff --git a/agreement_sale/security/ir.model.access.csv b/agreement_sale/security/ir.model.access.csv index 4b3915cf..f6e188f4 100644 --- a/agreement_sale/security/ir.model.access.csv +++ b/agreement_sale/security/ir.model.access.csv @@ -1,2 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink agreement.access_agreement_full,Full access on agreement grp,agreement.model_agreement,sales_team.group_sale_manager,1,1,1,1 +agreement_sale.access_agreement_type_full,Full access on agreement type grp,agreement.model_agreement_type,sales_team.group_sale_manager,1,1,1,1 +agreement_sale.access_agreement_type_read,Read access on agreement grp,agreement.model_agreement_type,base.group_user,1,0,0,0 diff --git a/agreement_sale/views/agreement.xml b/agreement_sale/views/agreement.xml index 43a2ea5d..cc30d5ce 100644 --- a/agreement_sale/views/agreement.xml +++ b/agreement_sale/views/agreement.xml @@ -2,7 +2,9 @@ - + diff --git a/agreement_sale/views/res_config_settings.xml b/agreement_sale/views/res_config_settings.xml new file mode 100644 index 00000000..1a24962c --- /dev/null +++ b/agreement_sale/views/res_config_settings.xml @@ -0,0 +1,48 @@ + + + + + res.config.settings.view.form.inherit.agreement + res.config.settings + + + + +

Agreements

+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
diff --git a/agreement_sale/views/sale_order.xml b/agreement_sale/views/sale_order.xml new file mode 100644 index 00000000..e7e5b5ea --- /dev/null +++ b/agreement_sale/views/sale_order.xml @@ -0,0 +1,19 @@ + + + + sale.order.agreement.form.view + sale.order + + + + + + + + + + + +