[IMP] sale_stock: multiple improvements

1) Warning message if quantity is changed on a confirmed SO

2) Cancel related procurements when a SO is cancelled
This commit is contained in:
Nicolas Martinelli
2015-09-22 16:24:11 +02:00
parent ced4bf5539
commit 0037547e8a
2 changed files with 27 additions and 1 deletions
+12 -1
View File
@@ -139,6 +139,12 @@ msgstr ""
msgid "Order Routing"
msgstr ""
#. module: sale_stock
#: code:addons/sale_stock/sale_stock.py:148
#, python-format
msgid "Ordered quantity changed!"
msgstr ""
#. module: sale_stock
#: model:ir.model.fields,field_description:sale_stock.field_sale_order_line_product_packaging
msgid "Packaging"
@@ -253,6 +259,12 @@ msgstr ""
msgid "Warning"
msgstr ""
#. module: sale_stock
#: code:addons/sale_stock/sale_stock.py:149
#, python-format
msgid "You have changed the quantity ordered! If the quantity was decreased, you need to modify manually the delivery order."
msgstr ""
#. module: sale_stock
#: code:addons/sale_stock/sale_stock.py:137
#, python-format
@@ -264,4 +276,3 @@ msgstr ""
#: model:ir.model,name:sale_stock.model_sale_config_settings
msgid "sale.config.settings"
msgstr ""
+15
View File
@@ -70,6 +70,11 @@ class SaleOrder(models.Model):
result['res_id'] = pick_ids[0]
return result
@api.multi
def action_cancel(self):
self.order_line.mapped('procurement_ids').cancel()
super(SaleOrder, self).action_cancel()
@api.multi
def _prepare_invoice(self):
invoice_vals = super(SaleOrder, self)._prepare_invoice()
@@ -141,6 +146,16 @@ class SaleOrderLine(models.Model):
return {'warning': warning_mess}
return {}
@api.onchange('product_uom_qty')
def _onchange_product_uom_qty(self):
if self.state == 'sale' and self.product_id.type != 'service':
warning_mess = {
'title': _('Ordered quantity changed!'),
'message' : _('You have changed the quantity ordered! If the quantity was decreased, you need to modify manually the delivery order.'),
}
return {'warning': warning_mess}
return {}
@api.multi
def _prepare_order_line_procurement(self, group_id=False):
vals = super(SaleOrderLine, self)._prepare_order_line_procurement(group_id=group_id)