diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index 3249c41d..1f79e372 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -259,8 +259,11 @@ class SaleOrder(models.Model): if origin: order_id = self.search([('origin', '=', origin)], order='id DESC',limit=1) if order_id and order_id.state != 'cancel': + if order_id.state == 'sale' and (order_id.assembly_state == 'created'): + vals['assembly_state'] = 'approved' + vals['message_post'] = 'PG9 autoreleased' order_id.write(vals) - if (order_id.state == 'draft' or order_id.state == 'sent') and order_id.assembly_state == 'created': + if (order_id.state == 'draft' or order_id.state == 'sent') and (order_id.assembly_state == 'created'): order_id.action_confirm() return {'id': order_id.id, 'name': order_id.name} else: @@ -576,10 +579,20 @@ class SaleOrder(models.Model): def action_confirm(self): # change name on order confirmation # if self.name.startswith('ATOF'): + new_vals = {} if self.name[2:4] == 'OF': # new_name = re.sub(r"^ATOF", "ATOC", self.name) new_name = ''.join((self.name[:2],'OC',self.name[4:])) - self.name = new_name +# self.name = new_name + new_vals['name'] = new_name + + pg_release_mode = self.env['ir.config_parameter'].get_param('pg_release_mode','MANUAL') + if (self.confirmation_nr and self.confirmation_nr != '') and self.order_type == 'D' and pg_release_mode == 'auto': +# self.assembly_state = 'approved' + new_vals['assembly_state'] = 'approved' + new_vals['message_post'] = 'PG9 autoreleased' + + self.write(new_vals) return super(SaleOrder, self).action_confirm() @api.model