odooodoo-15odoo-16

Pass Field Value From stock.scrap to account.move.line


I need to pass Analytic Account field value which exist in location that I created in stock.location to (journal entry) when I try to validate scrap enter image description here

I searched about the method which passes the account informations to jornal entry I cant find any relation between stock.scrap and account.move


Solution

  • Solution : - override analytic_distribution field in account.move.line - then make it related to account.move (move_id) that has a relation between stock.move (stock_move_id) which created automatically when stock.scrap validated so the field look like : analytic_distribution = fields.Json( 'Analytic Account', compute="_compute_analytic_distribution", store=True, copy=True, readonly=False,precompute=True,related='move_id.stock_move_id.scrap_location_id.analytic_distribution')