Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
2881 Vues

How do I do this?

Cheers,

Rob

Avatar
Ignorer
Auteur

I know how to create fields related to fields that I can edit. What I want to do is pick up description_picking from the products on the BOMS. I'm not sure how to use the suggested answer.

Hi, you can override the attribute you need :

Class the_old_you_need_to_change

_inherit=the_old_class

description_picking = fields.One2many('model', 'the attribute you want to link', [...] )

Class you_class

your_attribute_to_link = [...]

I hope this help !

Auteur

I get an error when I try to do this (help please? Thanks for the help so far):

class sms(models.Model):

_inherit = 'mrp.bom.line'

sms_location = fields.One2many(string='StockLoc', related='product_id.description_picking', readonly='True')

If I understand well, you have :

class ProductTemplate(models.Model):

[...]

description_picking = fields.Text('Description on Picking', translate=True)

[...]

this already exist and you are creating this

class sms(models.Model):

_inherit = 'mrp.bom.line'

sms_location = fields.One2many(string='StockLoc', related='product_id.description_picking', readonly='True')

where you want sms_location to be equal to the "description_picking" field of the product linked to you class (by product_id).

So your sms_location is also a String ?

If it is, try this

sms_location =fields.Text(string='StockLoc', related='product_id.description_picking', readonly='True')

If it don't work or don't do what you want, can you give more details about the error you get ?

Auteur

That makes perfect sense. Will try it in a minute. Thanks,

Now I just need to add it to the BOM lines. Do you know how to add it to the BOM reports? Or should I start a new question for that?

Rob

Sorry I don't know anything about report. Good luck with you project !

Meilleure réponse

Hi Robert Price,

you can using related="..." for new api:

ex:

product_tmpl_id = fields.Many2one( 'product.template', 'Product Template', related='product_id.product_tmpl_id', help="Technical: used in views")

Avatar
Ignorer
Publications associées Réponses Vues Activité
1
nov. 24
20745
1
sept. 23
3511
3
mai 23
6135
7
avr. 23
49523
1
déc. 22
8250