Help

0

Get custom field's value from BoM to production order

Avatar
Parker D

Hello there :)

I've managed to add some custom code to get some extra fields onto the production order and it's report. Now I thought it would be better if one of the fields would also be on the bill of material, but I have no idea how to get the data from there to the new production order, which is later based on this BoM.

It is a many2one field for which I created a custom model:

class FinishTypes(models.Model):
_name = 'bom.finishtypes'
_description = 'How to finish the edges.'
_rec_name = 'name'

name = fields.Char(string='Finishing Types', help='The way the edges have to be finished, e.g. polished.', required=True)

I then added this field to the mrp.production model: 

class POfinishtypes(models.Model):
_inherit = 'mrp.production'

finish_type_id = fields.Many2one('bom.finishtypes', string='Finishing Types', help='The way the edges have to be finished, e.g. polished.', size=255)

And then I added this field to the PO form and report.

Do I have to make a similar field on the BoM? And if so, how do I get it's data to the production order's draft? I am obviously not a pro developer...

We use Odoo 14 Enterprise, btw.

Avatar
Discard