Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1442 Lượt xem
def process_invoice(self):
self = self.with_user(SUPERUSER_ID)
order_ids = self.order_ids.filtered(lambda order: order.state == 'draft')
for order in order_ids:
order.action_confirm()
moves = order._create_invoices(final=False)
for move in moves:
new_quantity = 1
new_price_unit = 200
for line in move.invoice_line_ids:
line.update(line._get_price_total_and_subtotal(quantity=new_quantity,price_unit=new_price_unit))
price_subtotal = line._get_price_total_and_subtotal(quantity=new_quantity,price_unit= new_price_unit).get('price_subtotal')
line.update(line._get_fields_onchange_balance(quantity=new_quantity, price_subtotal=price_subtotal, force_computation=True))

How to use 

_get_price_total_and_subtotal

and

_get_fields_onchange_balance

to write 'quantity' or 'price_unit'?

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi , in your previous question i have updated the answer and i encountered the same error as you and work, please check

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,
Pass check_move_validity as True in the context and see if it makes any difference.

Sample:

move.with_context(check_move_validity=False)._onchange_currency()


Also you can trigger the function _recompute_dynamic_lines
Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 23
2250
1
thg 10 22
3726
1
thg 1 25
1294
2
thg 1 24
1503
4
thg 1 24
3252