diff --git a/stock_analytic/models/stock_move.py b/stock_analytic/models/stock_move.py index d630351d1a..a39340211f 100644 --- a/stock_analytic/models/stock_move.py +++ b/stock_analytic/models/stock_move.py @@ -6,13 +6,24 @@ # Copyright 2023 Quartile Limited # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, models +from odoo import api, fields, models class StockMove(models.Model): _name = "stock.move" _inherit = ["stock.move", "analytic.mixin"] + analytic_distribution = fields.Json( + inverse="_inverse_analytic_distribution", + ) + + def _inverse_analytic_distribution(self): + """If analytic distribution is set on move, write it on all move lines""" + for move in self: + move.move_line_ids.write( + {"analytic_distribution": move.analytic_distribution} + ) + def _prepare_account_move_line( self, qty, cost, credit_account_id, debit_account_id, svl_id, description ):