Skip to Content
Menú
This question has been flagged
analytic_account_id = fields.Many2one(
   "account.analytic.account", string="Analytic Account Type", store=True)

And then

_inherit = "stock. valuation.layer"

Here, add the analytic account to the account.move dictionary

account_move = self.env["account.move"].sudo().create(account_move_vals)
for lines in self.account_move_id.line_ids:
   lines. write(
       {
           "analytic_account_id": self.stock_move_id.account_analytic_id.id
       }
   )
account_move._post()

 
This section is provided by cybrosys, and its intended to add an analytic account field on the stock.move.line so we can track the cost of the products in a specific analytic account. When implemented I am getting the error that : "account_move_vals" is not defined.

How can I overcome this and fix it in Odoo 16?

Avatar
Descartar
Best Answer

May i know if you have a solution for this? 

Avatar
Descartar
Best Answer

You need to define the account_move_line object, something like below. Also look out for any other required fields that might be in your model

account_move_line =  {
"date": fields.Date.today(),            
'move_type': 'entry',            
'journal_id': [Your journal ID],            
'partner_id': [Your Partner ID],           
'ref': [Your Refernce] ,            
'payment_reference': [Your Payment Ref],            
'company_id': [Company ID],            
'currency_id': [Currency ID]
}

Avatar
Descartar
Autor

I am doing it using automated action, can you help me fix the code?

Related Posts Respostes Vistes Activitat
1
de jul. 24
2077
6
de maig 24
21570
3
de març 16
6590
2
de febr. 25
1701
2
de maig 23
2423