Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4480 Widoki

hi all

i added a field in 'sale.order.line' called 'sale_order_dimension'  i want to view this field value in 'stock.move' but i want to change value in stock.move without reflect
so i added

class InheritStockMove(models.Model):
_inherit = 'stock.move'

def _get_dimension_value(self):
# what should i add here


product_dimension = fields.Char(string="Dimension", default=_get_dimension_value)


Any idea ?
Thanks
Awatar
Odrzuć
Najlepsza odpowiedź

There is a field called "sale_line_id" in "stock.move" object. It will store the reference for the sales order line if the move is created from the sale line.

So you can use this field to fetch the value of any field of so line. You can simply create a related field using "sale_line_id" field.

Use the following code:

product_dimension = fields.Char("Dimension", related='sale_line_id.product_dimension')


Awatar
Odrzuć
Autor

it gets the value but i want to edit that field in stock.move but value doesn't reflect in sale.order.line

If you want to change the value in stock move and don't want to reflect it in sale line, add store=True in the related field.

product_dimension = fields.Char("Dimension", related='sale_line_id.product_dimension', store=True)

Autor

i added store=True in related field but still reflect the value in (dimension in sale order line) original field ...

Powiązane posty Odpowiedzi Widoki Czynność
0
paź 23
43032
1
paź 23
4785
2
lut 23
5254
1
lis 22
2416
1
sty 22
2069