[FIX]account_budget_forecast:odoo cant copy multiple times on the same record One2many fields that all point to analic_id, so pass them to copy=False
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
from odoo import models, fields, _, api
|
||||
from odoo.exceptions import Warning
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
@@ -49,9 +51,12 @@ class SaleOrder(models.Model):
|
||||
name = self.analytic_account_id.name.replace(self.name, record.name)
|
||||
else:
|
||||
name = "%s: %s" % (self.analytic_account_id.name, record.name)
|
||||
record.analytic_account_id = self.analytic_account_id.copy(
|
||||
default=dict(name=name)
|
||||
)
|
||||
try:
|
||||
copied_account = self.analytic_account_id.copy(default={"name": name})
|
||||
if copied_account:
|
||||
record.analytic_account_id = copied_account
|
||||
except Exception as e:
|
||||
_logger.error("Failed to copy analytic account for sale order %s: %s", self.name, e)
|
||||
return record
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user