[IMP] sale: add option to set a SO to done automatically
This option will set a SO automatically to Done when it is confirmed. The purpose is to prevent a user to modify a SO after confirmation, as it was the case up to v8.0.
This commit is contained in:
@@ -1794,3 +1794,17 @@ msgstr ""
|
||||
msgid "unknown"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: selection:sale.config.settings,auto_done_setting:0
|
||||
msgid "Allow to edit sales order from the 'Sales Order' menu (not from the Quotation menu)"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: selection:sale.config.settings,auto_done_setting:0
|
||||
msgid "Never allow to modify a confirmed sale order"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: model:ir.model.fields,field_description:sale.field_sale_config_settings_auto_done_setting
|
||||
msgid "Sale Order Modification"
|
||||
msgstr ""
|
||||
|
||||
@@ -68,6 +68,10 @@ class sale_configuration(osv.TransientModel):
|
||||
'deposit_product_id_setting': fields.many2one('product.product', 'Default Advance Product',\
|
||||
domain="[('type', '=', 'service')]",\
|
||||
help='Default product used for payment advances'),
|
||||
'auto_done_setting': fields.selection([
|
||||
(0, "Allow to edit sales order from the 'Sales Order' menu (not from the Quotation menu)"),
|
||||
(1, "Never allow to modify a confirmed sale order")
|
||||
], "Sale Order Modification"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
@@ -85,6 +89,11 @@ class sale_configuration(osv.TransientModel):
|
||||
res = self.pool.get('ir.values').set_default(cr, uid, 'sale.config.settings', 'deposit_product_id_setting', deposit_product_id.id)
|
||||
return res
|
||||
|
||||
def set_auto_done_defaults(self, cr, uid, ids, context=None):
|
||||
auto_done = self.browse(cr, uid, ids, context=context).auto_done_setting
|
||||
res = self.pool.get('ir.values').set_default(cr, uid, 'sale.config.settings', 'auto_done_setting', auto_done)
|
||||
return res
|
||||
|
||||
def onchange_sale_price(self, cr, uid, ids, sale_pricelist_setting, context=None):
|
||||
if sale_pricelist_setting == 'percentage':
|
||||
return {'value': {'group_product_pricelist': True, 'group_sale_pricelist': True, 'group_pricelist_item': False}}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<field name="group_discount_per_so_line" widget="radio"/>
|
||||
<field name="module_website_quote" widget="radio"/>
|
||||
<field name="module_sale_margin" widget="radio"/>
|
||||
<field name="auto_done_setting" widget="radio"/>
|
||||
</group>
|
||||
<group name="manage_price">
|
||||
<label for="sale_pricelist_setting" string="Sale Price"/>
|
||||
|
||||
@@ -390,6 +390,8 @@ class SaleOrder(models.Model):
|
||||
if line.product_id.invoice_policy == 'cost':
|
||||
order._create_analytic_account()
|
||||
break
|
||||
if self.env['ir.values'].get_default('sale.config.settings', 'auto_done_setting'):
|
||||
self.action_done()
|
||||
|
||||
@api.multi
|
||||
def _create_analytic_account(self, prefix=None):
|
||||
|
||||
Reference in New Issue
Block a user