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

hello,

i add two char custom field x_IDfornitore and x_IDfornitore 2 to product.template

now i would like to show them in purchase order lines because i need them to be printed in the report when i send the request to my supplier.

Best option is to add them directly to the desctiption  so that my purchase order lines looks like:

Product / Description (name+x_IDfornitore+x_IDfornitore2) / ecc ecc or if it's more simple to just add two column in the purchase order with the two custom field.

i'm newbi to programming so any help would great


thanks

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

Hi Mauro,

It will be better to go ahead with description, make the description field as the combination of the three, in the onchange of the products you can write the values to description.

If you use this method you don't want to add further changes in the report, as already the description is there in the report.

If you are adding the two new fields separately, then you have to write the values into these fields while changing the product , also you have to customize the report to add this fields in it.

So it will be better to go ahead with the first solution.

class PurchaseOrderExtend(models.Model):
_inherit = 'purchase.order.line'

@api.onchange('product_id')
def SetDescriptions(self):
if self.product_id:
self.name = self.product_id.display_name + self.product_id.new_field_1 + \
self.product_id.new_field_2
self.price_unit = self.product_id.lst_price

Thanks

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

thanks,

i agree, now i just need to understand how to modify the code exactly


Ảnh đại diện
Huỷ bỏ

I have updated my answer with the code, please go through it

Tác giả

thank you very much ;)

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 4 15
5802
0
thg 4 15
5994
1
thg 8 24
1924
1
thg 3 15
6429
0
thg 3 15
3096