File tree 1 file changed +19
-17
lines changed
purchase_stock_price_unit_sync/models
1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -33,21 +33,23 @@ def stock_price_unit_sync(self):
33
33
bom_type = "phantom" ,
34
34
):
35
35
continue
36
- line .move_ids .write ({"price_unit" : line ._get_stock_move_price_unit ()})
37
- # Apply sudo() to avoid access errors with users without Inventory > Admin
38
- # permissions.
39
- svls = (
40
- line .move_ids .sudo ()
41
- .mapped ("stock_valuation_layer_ids" )
42
- .filtered (
43
- # Filter children SVLs (like landed cost)
44
- lambda x : not x .stock_valuation_layer_id
36
+ moves = line .move_ids .filtered (lambda m : m .state == "done" )
37
+ if moves :
38
+ moves .write ({"price_unit" : line ._get_stock_move_price_unit ()})
39
+ # Apply sudo() to avoid access errors with users without Inventory > Admin
40
+ # permissions.
41
+ svls = (
42
+ moves .sudo ()
43
+ .mapped ("stock_valuation_layer_ids" )
44
+ .filtered (
45
+ # Filter children SVLs (like landed cost)
46
+ lambda x : not x .stock_valuation_layer_id
47
+ )
48
+ )
49
+ svls .write (
50
+ {
51
+ "unit_cost" : line .with_context (
52
+ skip_stock_price_unit_sync = True
53
+ )._get_stock_move_price_unit (),
54
+ }
45
55
)
46
- )
47
- svls .write (
48
- {
49
- "unit_cost" : line .with_context (
50
- skip_stock_price_unit_sync = True
51
- )._get_stock_move_price_unit (),
52
- }
53
- )
You can’t perform that action at this time.
0 commit comments