Show warning when output product's list price is empty
issue10791 review369771002
This commit is contained in:
1 parent
f1900a72da
commit
e33534a89f
4 files changed
+25
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -6,5 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<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>
|
||||
@@ -8,6 +8,7 @@ from itertools import chain
|
||||
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.company.model import employee_field, set_employee
|
||||
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 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
|
||||
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 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
|
||||
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))
|
||||
|
||||
Reference in new issue
Block a user