[FIX] sale_stock: onchange warning for packaging

This commit is contained in:
Adrien Dieudonne
2015-09-15 14:20:19 +02:00
committed by Richard Mathot
parent d210744ef0
commit 45d53ec465
2 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -136,7 +136,7 @@
<field name="seller_ids"/>
<group name="packaging" string="Packaging"
colspan="4"
attrs="{'invisible':[('type', 'not in', ['product, consu'])]}"
attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}"
groups="product.group_stock_packaging">
<field name="packaging_ids" nolabel="1"/>
</group>
+6 -4
View File
@@ -172,15 +172,17 @@ class SaleOrderLine(models.Model):
@api.multi
def _check_package(self):
default_uom = self.product_id.product_uom
default_uom = self.product_id.uom_id
pack = self.product_packaging
qty = self.product_uom_qty
q = self.product_id.product_uom._compute_qty(pack.qty, default_uom)
q = self.env['product.uom']._compute_qty_obj(default_uom, pack.qty, self.product_uom)
if qty and q and (qty % q):
newqty = qty - (qty % q) + q
return {
'title': _('Warning!'),
'message': _("This product is packaged by %d %s. You should sell %d %s.") % (pack.qty, default_uom, newqty, default_uom)
'warning': {
'title': _('Warning'),
'message': _("This product is packaged by %d . You should sell %d .") % (pack.qty, newqty),
},
}
return {}