diff --git a/product_standard_price_restriction/__manifest__.py b/product_standard_price_restriction/__manifest__.py index 5f468c6..1756f0f 100644 --- a/product_standard_price_restriction/__manifest__.py +++ b/product_standard_price_restriction/__manifest__.py @@ -10,6 +10,7 @@ "license": "AGPL-3", "depends": ["product"], "data": [ + "views/res_config_setting_views.xml", "views/product_template_views.xml" ], "installable": True, diff --git a/product_standard_price_restriction/models/__init__.py b/product_standard_price_restriction/models/__init__.py index e8fa8f6..b63e168 100644 --- a/product_standard_price_restriction/models/__init__.py +++ b/product_standard_price_restriction/models/__init__.py @@ -1 +1,3 @@ +from . import res_company +from . import res_config_settings from . import product_template diff --git a/product_standard_price_restriction/models/product_template.py b/product_standard_price_restriction/models/product_template.py index 7242b0b..414eda0 100644 --- a/product_standard_price_restriction/models/product_template.py +++ b/product_standard_price_restriction/models/product_template.py @@ -14,19 +14,6 @@ class ProductTemplate(models.Model): def write(self, vals): if "standard_price" in vals: if not vals.get('update_cost', self.update_cost): - raise UserError( - _( - "You are about to update the cost. This field is " - "auto-calculated by Odoo and is an 'Weighted Average Value' of " - "one unit of this product in current inventory. This is " - "not the 'Price' or 'Cost' to buy this item -- that is " - "set in the 'Purchase' TAB. This value should not be " - "modified unless there are very unusual circumstances. " - "In such a situation, please set the 'Update Cost' " - "field to 'True' and save the record again. Additionally, " - "please make sure to write a detailed 'Log' below " - "of what you are changing (from what to what) and why." - ) - ) + raise UserError(_(self.company_id.product_standard_price_restriction)) vals['update_cost'] = False return super(ProductTemplate, self).write(vals) diff --git a/product_standard_price_restriction/models/res_company.py b/product_standard_price_restriction/models/res_company.py new file mode 100644 index 0000000..6643473 --- /dev/null +++ b/product_standard_price_restriction/models/res_company.py @@ -0,0 +1,9 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models + +class ResCompany(models.Model): + _inherit = "res.company" + + product_standard_price_restriction = fields.Text() diff --git a/product_standard_price_restriction/models/res_config_settings.py b/product_standard_price_restriction/models/res_config_settings.py new file mode 100644 index 0000000..264ee21 --- /dev/null +++ b/product_standard_price_restriction/models/res_config_settings.py @@ -0,0 +1,9 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models + +class ResConfigSetting(models.TransientModel): + _inherit = "res.config.settings" + + product_standard_price_restriction = fields.Text(related="company_id.product_standard_price_restriction", readonly=False) diff --git a/product_standard_price_restriction/views/res_config_setting_views.xml b/product_standard_price_restriction/views/res_config_setting_views.xml new file mode 100644 index 0000000..3bfb442 --- /dev/null +++ b/product_standard_price_restriction/views/res_config_setting_views.xml @@ -0,0 +1,34 @@ + + + + res.config.settings.view.form.inherit + res.config.settings + + + + +
+
+
+
+
+ + + +