Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Oct 24, 2023
1 parent 3836454 commit 4dc2d64
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 14 deletions.
1 change: 1 addition & 0 deletions product_standard_price_restriction/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"license": "AGPL-3",
"depends": ["product"],
"data": [
"views/res_config_setting_views.xml",
"views/product_template_views.xml"
],
"installable": True,
Expand Down
2 changes: 2 additions & 0 deletions product_standard_price_restriction/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import res_company
from . import res_config_settings
from . import product_template
15 changes: 1 addition & 14 deletions product_standard_price_restriction/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 9 additions & 0 deletions product_standard_price_restriction/models/res_company.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="25" />
<field
name="inherit_id"
ref="product.res_config_settings_view_form"
/>
<field name="arch" type="xml">
<xpath
expr="//field[@name='product_weight_in_lbs']/../../../.."
position="after"
>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<label
for="product_standard_price_restriction"
string="Product Standard Price Restriction"
/>
<div class="text-muted">
Error message for product standard price restriction
</div>
<div class="text-muted">
<field name="product_standard_price_restriction" />
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 4dc2d64

Please sign in to comment.