changeset f1d5c4d5c93d in modules/production:default
details:
https://hg.tryton.org/modules/production?cmd=changeset&node=f1d5c4d5c93d
description:
Show warning when output product's list price is empty
issue10791
review369771002
diffstat:
CHANGELOG | 1 +
exceptions.py | 7 +++++++
message.xml | 3 +++
production.py | 14 ++++++++++++++
4 files changed, 25 insertions(+), 0 deletions(-)
diffs (76 lines):
diff -r 0e8e200bb25b -r f1d5c4d5c93d CHANGELOG
--- a/CHANGELOG Wed Oct 06 00:50:19 2021 +0200
+++ b/CHANGELOG Wed Oct 13 11:08:26 2021 +0200
@@ -1,3 +1,4 @@
+* Show warning when output product's list price is empty
* Remove unique product constraint on BOM
Version 6.0.0 - 2021-05-03
diff -r 0e8e200bb25b -r f1d5c4d5c93d exceptions.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exceptions.py Wed Oct 13 11:08:26 2021 +0200
@@ -0,0 +1,7 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from trytond.exceptions import UserWarning
+
+
+class CostWarning(UserWarning):
+ pass
diff -r 0e8e200bb25b -r f1d5c4d5c93d message.xml
--- a/message.xml Wed Oct 06 00:50:19 2021 +0200
+++ b/message.xml Wed Oct 13 11:08:26 2021 +0200
@@ -6,5 +6,8 @@
<record model="ir.message" id="msg_recursive_bom">
<field name="text">You cannot create a recursive BOM for product
"%(product)s".</field>
</record>
+ <record model="ir.message" id="msg_missing_product_list_price">
+ <field name="text">The product "%(product)s" on production
"%(production)s" does not have any list price defined.</field>
+ </record>
</data>
</tryton>
diff -r 0e8e200bb25b -r f1d5c4d5c93d production.py
--- a/production.py Wed Oct 06 00:50:19 2021 +0200
+++ b/production.py Wed Oct 13 11:08:26 2021 +0200
@@ -8,6 +8,7 @@
from sql import Null
from sql.conditionals import Coalesce
+from trytond.i18n import gettext
from trytond.model import ModelView, ModelSQL, Workflow, fields, dualmethod
from trytond.pyson import Eval, Bool, If
from trytond.pool import Pool
@@ -17,6 +18,9 @@
from trytond.modules.product import price_digits, round_price
from trytond.modules.stock.shipment import ShipmentAssignMixin
+from .exceptions import CostWarning
+
+
BOM_CHANGES = ['bom', 'product', 'quantity', 'uom', 'warehouse', 'location',
'company', 'inputs', 'outputs']
@@ -536,6 +540,7 @@
pool = Pool()
Uom = pool.get('product.uom')
Move = pool.get('stock.move')
+ Warning = pool.get('res.user.warning')
moves = []
for production in productions:
@@ -575,6 +580,15 @@
for output in outputs:
product = output.product
list_price = product.list_price_used
+ if list_price is None:
+ warning_name = Warning.format(
+ 'production_missing_list_price', [product])
+ if Warning.check(warning_name):
+ raise CostWarning(warning_name,
+ gettext(
+ 'production.msg_missing_product_list_price',
+ product=product.rec_name,
+ production=production.rec_name))
product_price = (Decimal(str(output.quantity))
* Uom.compute_price(
product.default_uom, list_price, output.uom))