Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
3223 Zobrazení

I have added some fields in product.template. I need to display the field in sale_order_line in sales module. How can I make it possible?


Avatar
Zrušit
Nejlepší odpověď

Hi,

You can write a onchange function for the product field in the order line. In the onchange function write the value to new field or you can make the new field as related field.

@api.onchange('product_id')
def function_name(self):
if self.product_id:
self.new_field_name = self.product_id.field_in_product

Thanks

Avatar
Zrušit
Autor

thank you Niyas :)

Nejlepší odpověď

Hi Sarina,

You can change price_unit field to a functional field.


@api.one
@api.depends('mrp', 'discount')
def _compute_price_unit(self)
    self.price_unit =  self.mrp - self.discount
price_unit = fields.Float('Unit Price', compute='_compute_price_unit', store=True)


If you don't want to store the value in database, then you can use this:


@api.one
def _compute_price_unit(self)
    self.price_unit =  self.mrp - self.discount
price_unit = fields.Float('Unit Price', compute='_compute_price_unit')
Avatar
Zrušit
Autor Nejlepší odpověď

Can I calculate price_unit in sale_order line if I put a new field in sale order line like

price_unit=mrp-discount

Avatar
Zrušit

Please see the the above answer for price_unit calculation by functional field

Related Posts Odpovědi Zobrazení Aktivita
2
čvc 25
4999
2
pro 24
7990
2
lis 24
28791
2
kvě 24
7664
3
bře 24
7116