I have a related many2one field in my stock operations. It is related from the purchase order; ex: if your PO has the project NARANJA, the picking from that PO will have NARANJA inherted.
The problem is that when I create I move WITHOUT PO, the analytic_account_id is not saved correctly.
The code from the field:
class Picking(models.Model):
_inherit = 'stock.picking'
analytic_account_id = fields.Many2one(
comodel_name='account.analytic.account', string='Project', related='purchase_id.analytic_account_id',
store=True,)