changeset e37ed7d8afa8 in modules/purchase_requisition:default details: https://hg.tryton.org/modules/purchase_requisition?cmd=changeset;node=e37ed7d8afa8 description: Add secondary unit
issue8239 review271131003 diffstat: CHANGELOG | 1 + purchase.py | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diffs (62 lines): diff -r d0ded81a618b -r e37ed7d8afa8 CHANGELOG --- a/CHANGELOG Mon May 20 17:29:12 2019 +0200 +++ b/CHANGELOG Sun Jul 28 14:34:20 2019 +0200 @@ -1,3 +1,4 @@ +* Remove domain constraint on unit * Use processing delay to process approved requisition * Allow reset to draft approved but not processed requisition diff -r d0ded81a618b -r e37ed7d8afa8 purchase.py --- a/purchase.py Mon May 20 17:29:12 2019 +0200 +++ b/purchase.py Sun Jul 28 14:34:20 2019 +0200 @@ -439,17 +439,9 @@ 'required': Bool(Eval('product')), 'readonly': _states['readonly'], }, - domain=[ - If(Bool(Eval('product_uom_category')), - ('category', '=', Eval('product_uom_category')), - ('category', '!=', -1)), - ], - depends=['product', 'product_uom_category'] + _depends) + depends=['product'] + _depends) unit_digits = fields.Function( fields.Integer('Unit Digits'), 'on_change_with_unit_digits') - product_uom_category = fields.Function( - fields.Many2One('product.uom.category', 'Product Uom Category'), - 'on_change_with_product_uom_category') unit_price = fields.Numeric( 'Unit Price', digits=price_digits, states=_states, depends=_depends) amount = fields.Function( @@ -490,11 +482,6 @@ amount = self.requisition.currency.round(amount) return amount - @fields.depends('product') - def on_change_with_product_uom_category(self, name=None): - if self.product: - return self.product.default_uom_category.id - @fields.depends('unit') def on_change_with_unit_digits(self, name=None): if self.unit: @@ -523,12 +510,13 @@ supplier = self.supplier # TODO compute purchase_date for product_supplier - if self.product: - uom = self.product.purchase_uom or self.product.default_uom - quantity = Uom.compute_qty(self.unit, self.quantity, uom) - else: - uom = self.unit - quantity = self.quantity + uom = self.unit + quantity = self.quantity + if (self.product + and self.product.purchase_uom.category == self.unit.category): + uom = self.product.purchase_uom + quantity = Uom.compute_qty(self.unit, self.quantity, + uom, round=True) return Request( product=self.product,