[IMP] sale: split _create_analytic_account() for potential inheritance
analytic account data preparation is now a hook method This allows to modify the creation method without unecessary updates closes odoo/odoo#35784 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
committed by
Martin Trigaux
parent
c0d3d7e994
commit
df0cff2628
@@ -693,18 +693,28 @@ class SaleOrder(models.Model):
|
||||
|
||||
def _get_forbidden_state_confirm(self):
|
||||
return {'done', 'cancel'}
|
||||
|
||||
def _prepare_analytic_account_data(self, prefix=None):
|
||||
"""
|
||||
Prepare method for analytic account data
|
||||
|
||||
:param prefix: The prefix of the to-be-created analytic account name
|
||||
:type prefix: string
|
||||
:return: dictionary of value for new analytic account creation
|
||||
"""
|
||||
name = self.name
|
||||
if prefix:
|
||||
name = prefix + ": " + self.name
|
||||
return {
|
||||
'name': name,
|
||||
'code': self.client_order_ref,
|
||||
'company_id': self.company_id.id,
|
||||
'partner_id': self.partner_id.id
|
||||
}
|
||||
|
||||
def _create_analytic_account(self, prefix=None):
|
||||
for order in self:
|
||||
name = order.name
|
||||
if prefix:
|
||||
name = prefix + ": " + order.name
|
||||
analytic = self.env['account.analytic.account'].create({
|
||||
'name': name,
|
||||
'code': order.client_order_ref,
|
||||
'company_id': order.company_id.id,
|
||||
'partner_id': order.partner_id.id
|
||||
})
|
||||
analytic = self.env['account.analytic.account'].create(order._prepare_analytic_account_data(prefix))
|
||||
order.analytic_account_id = analytic
|
||||
|
||||
def _amount_by_group(self):
|
||||
|
||||
Reference in New Issue
Block a user