Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
5180 Prikazi

Hi,

how can I update a stock.move field in sale.order in an onchange method?

I have the following workaround:

@api.onchange("test_field")
def _on_change(self):
    list = []
    for line in self.order_line:
        for move in line.move_ids:
            move.update({'state': 'new_state'}) #not working! -> no error but no change on database
         list.append([1, self._origin.id, line])
self.update({'order_line': list }) #not working! -> error: AttributeError: 'sale.order.line' object has no attribute 'items'

What am I doing wrong here? Is there another possibility to change the move_line state from sale_order??

Thanks!!

Avatar
Opusti
Best Answer

Hi,


Please check this.


@api.onchange('test_field')

def _onchange_test_field(self):

    for line in self.order_line:

        for move in line.move_ids:

            move.state = 'new_state'


Hope it helps

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
sep. 23
5743
0
jun. 22
2203
1
jul. 20
3932
1
maj 20
8137
1
jan. 25
1717