[FIX] sale_stock: launch procurement rule and locked

If the user chose to "lock confirmed orders" in the sales's settings,
the procurements where not runned correctly and the associated delivery
orders were not created.

This issue is caused by the fact that `_action_launch_procurement_rule`
was done on done sale order line. We refactore the method so that we
call this method always when the sale order line are in `sale` state.

Fixes #20599
This commit is contained in:
Simon Lejeune
2017-10-31 17:20:46 +01:00
parent 3b91780bc0
commit ee2b9fae35
2 changed files with 10 additions and 6 deletions
+8 -3
View File
@@ -515,7 +515,7 @@ class SaleOrder(models.Model):
self.write({'state': 'sale'})
@api.multi
def action_confirm(self):
def _action_confirm(self):
for order in self.filtered(lambda order: order.partner_id not in order.message_partner_ids):
order.message_subscribe([order.partner_id.id])
self.write({
@@ -524,8 +524,6 @@ class SaleOrder(models.Model):
})
if self.env.context.get('send_email'):
self.force_quotation_send()
if self.env['ir.config_parameter'].sudo().get_param('sale.auto_done_setting'):
self.action_done()
# create an analytic account if at least an expense product
if any([expense_policy != 'no' for expense_policy in self.order_line.mapped('product_id.expense_policy')]):
@@ -534,6 +532,13 @@ class SaleOrder(models.Model):
return True
@api.multi
def action_confirm(self):
self._action_confirm()
if self.env['ir.config_parameter'].sudo().get_param('sale.auto_done_setting'):
self.action_done()
return True
@api.multi
def _create_analytic_account(self, prefix=None):
for order in self:
+2 -3
View File
@@ -34,11 +34,10 @@ class SaleOrder(models.Model):
procurement_group_id = fields.Many2one('procurement.group', 'Procurement Group', copy=False)
@api.multi
def action_confirm(self):
result = super(SaleOrder, self).action_confirm()
def _action_confirm(self):
super(SaleOrder, self)._action_confirm()
for order in self:
order.order_line._action_launch_procurement_rule()
return result
@api.depends('picking_ids')
def _compute_picking_ids(self):