mirror of
https://github.com/NaN-tic/trytond-stock_number_of_packages.git
synced 2023-12-14 07:52:52 +01:00
Ensure package_qty has a value before multiply it
This commit is contained in:
parent
cd2127e830
commit
b567635ce4
|
@ -26,8 +26,8 @@ class PackagedMixin:
|
|||
@fields.depends('product', 'package', methods=['package'])
|
||||
def on_change_product(self):
|
||||
super(PackagedMixin, self).on_change_product()
|
||||
if self.product and (not self.package
|
||||
or self.package.product != self.product.template):
|
||||
if self.product and (not self.package or
|
||||
self.package.product != self.product.template):
|
||||
if self.product.default_package:
|
||||
self.package = self.product.default_package
|
||||
self.on_change_package()
|
||||
|
@ -42,7 +42,8 @@ class PackagedMixin:
|
|||
package_qty = self.package.qty
|
||||
else:
|
||||
return
|
||||
if self.number_of_packages or self.number_of_packages == 0:
|
||||
if ((self.number_of_packages or self.number_of_packages == 0) and
|
||||
package_qty):
|
||||
self.quantity = self.number_of_packages * package_qty
|
||||
|
||||
@fields.depends('package', 'number_of_packages')
|
||||
|
|
Loading…
Reference in a new issue