Skip to Content
Menu
This question has been flagged
1 Reply
2867 Views

I want that a field called project in a po is copied to the same field in a stock picking operation. You can use a related field. The problem is that when I want to create a stock transfer I can't assign a project because of the relation.
Is there any alternative to say to odoo copy the value from the PO to the stock picking, and at the same time use the same field in other stock transfers?

Avatar
Discard
Best Answer

Hi Alejandro:

If you make it a Stored field, it will be picked up automatically in the stock picking form and you will be able to enter a value on other stock transfers.

Avatar
Discard
Author

It is a Stored field. Here you have the code

class PurchaseOrder(models.Model):

_inherit = 'purchase.order'

analytic_account_id = fields.Many2one(

string='Project', comodel_name='account.analytic.account', store=True)

class Picking(models.Model):

_inherit = 'stock.picking'

analytic_account_id = fields.Many2one(

related='purchase_id.analytic_account_id', string='Project', store='true')

You have a typo in stock.picking: store='true'

Change this to: store=True