changeset fbe18aba79f1 in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset;node=fbe18aba79f1
description:
Enforce the same category of UoM between invoice lines and origin
The origin lines compute the remaining quantity by converting the move
quantity
to the origin unit. So they must have the same category of UoM.
issue9142
review285011002
diffstat:
invoice.py | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diffs (23 lines):
diff -r 424989ac10ad -r fbe18aba79f1 invoice.py
--- a/invoice.py Tue Mar 17 20:08:12 2020 +0100
+++ b/invoice.py Tue Mar 17 23:26:58 2020 +0100
@@ -103,6 +103,19 @@
class Line(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
+ @fields.depends('origin')
+ def on_change_with_product_uom_category(self, name=None):
+ pool = Pool()
+ SaleLine = pool.get('sale.line')
+ category = super().on_change_with_product_uom_category(name=name)
+ # Enforce the same unit category as they are used to compute the
+ # remaining quantity to invoice and the quantity to ship.
+ # Use getattr as reference field can have negative id
+ if (isinstance(self.origin, SaleLine)
+ and getattr(self.origin, 'unit', None)):
+ category = self.origin.unit.category.id
+ return category
+
@property
def origin_name(self):
pool = Pool()