[FIX] sale: prevent confirmation of SO

Prevent the confirmation of a SO in state 'cancel' or 'done'.

opw-1881333
This commit is contained in:
Nicolas Martinelli
2018-09-06 15:05:09 +02:00
committed by Nicolas Martinelli
parent 765a3bf23f
commit 79a7d58a1c
2 changed files with 13 additions and 0 deletions
+6
View File
@@ -1209,6 +1209,12 @@ msgid "It is forbidden to modify the following fields in a locked order:\n"
"%s"
msgstr ""
#. module: sale
#: code:addons/sale/models/sale.py:551
#, python-format
msgid "It is not allowed to confirm an order in the following states: %s"
msgstr ""
#. module: sale
#: model:ir.model.fields,field_description:sale.field_report_all_channels_sales___last_update
#: model:ir.model.fields,field_description:sale.field_report_sale_report_saleproforma___last_update
+7
View File
@@ -547,11 +547,18 @@ class SaleOrder(models.Model):
@api.multi
def action_confirm(self):
if self._get_forbidden_state_confirm() & set(self.mapped('state')):
raise UserError(_(
'It is not allowed to confirm an order in the following states: %s'
) % (', '.join(self._get_forbidden_state_confirm())))
self._action_confirm()
if self.env['ir.config_parameter'].sudo().get_param('sale.auto_done_setting'):
self.action_done()
return True
def _get_forbidden_state_confirm(self):
return {'done', 'cancel'}
@api.multi
def _create_analytic_account(self, prefix=None):
for order in self: