[FIX] account_analytic_default: invoice, avoid account overwrite
Due to the following revision:
bdf630f9b8
When creating an invoice from a purchase order with an
analytic account set, the analytic account was no longer
copied on the invoice, as the analytic account that was added
thanks to
https://github.com/odoo/odoo/blob/9.0/addons/purchase/invoice.py#L53
was overwritten with `False` as `rec` was False
or if `rec` was True, it was overwritten with the analytic account
of `rec`.
opw-697702
This commit is contained in:
@@ -71,12 +71,11 @@ class account_invoice_line(osv.osv):
|
||||
return res
|
||||
|
||||
def _set_additional_fields(self, invoice):
|
||||
rec = self.env['account.analytic.default'].account_get(self.product_id.id, self.invoice_id.partner_id.id, self._uid,
|
||||
if not self.account_analytic_id:
|
||||
rec = self.env['account.analytic.default'].account_get(self.product_id.id, self.invoice_id.partner_id.id, self._uid,
|
||||
time.strftime('%Y-%m-%d'), company_id=self.company_id.id, context=self._context)
|
||||
if rec:
|
||||
self.account_analytic_id = rec.analytic_id.id
|
||||
else:
|
||||
self.account_analytic_id = False
|
||||
if rec:
|
||||
self.account_analytic_id = rec.analytic_id.id
|
||||
super(account_invoice_line, self)._set_additional_fields(invoice)
|
||||
|
||||
class stock_picking(osv.osv):
|
||||
|
||||
Reference in New Issue
Block a user