Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2622 Lượt xem

Hi all,

I need to create a field in invoice lines, with predefault = public_price but with the possibility to override this value.

Also, in case the product on the line is changed, the value must be updated.

I've tried with the following code, but it doesn't work:


    x_prod_list_price = fields.Float(required=False, related='product_id.list_price', readonly=False, store=False)


@api.multi
@api.onchange('product_id')
def _cust_onchange_product_id(self):
_logger.warning('_cust_onchange_product_id')
if not self.invoice_id:
_logger.warning('not self.invoice_id')
return
self.x_prod_list_price=self.product_id.list_price
_logger.warning('onchage prewrite x_prod_list_price = (%s)',self.product_id.list_price)
self.write({'x_prod_list_price': self.product_id.list_price})
_logger.warning('Onchage postwrite: (%s)', self.x_prod_list_price)
return




Any help?

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

If there is no need to present in view the x_prod_list_price with default value, You can set it's value in create(self,vals)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 21
2391
10
thg 7 20
15577
3
thg 1 19
6887
0
thg 4 18
3483
2
thg 7 24
2494