İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
10560 Görünümler

I added a field called "x_project_code" to the model "purchase.order.line", so i could insert a project code for each product so could evaluate how much I spent on every project.
how do i add this filed to the pivot table?
thanks :)

Avatar
Vazgeç
En İyi Yanıt

Hello, I couldn't find better way to do, but here is my solution, that worked for me.

  1. I inherited purchase.report model

  2. I've defined my custom field in it. Same field I have in purhcase.order.line as well.
    Example: dry_nuts = fields.Float('Expected Dry Nuts', readonly=True, group_operator="sum")

  3. I inherited purchase pivot view and added my custom field.
    Example: <field name="dry_nuts" type="measure" />

  4. In python file, where I inherited purchase.report, I copied complete query from purchase. report file and added additional query for my customs field.
    Example: sum(l.dry_nuts/u.factor*u2.factor) as dry_nuts

After that, dry_nuts are visible in purchase pivot table.

I think there is a better way to do it using ORM, so that there won't be need of copying all query from purchase.report, but I couldn't figure it out.


Hope this solution helps you too.

Avatar
Vazgeç

May i know what is the meant of l why we use it please explain it and my second question is what is meant of U and factor and why we use it please explain it

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Mar 15
5367
2
May 25
2227
0
Şub 25
1437
0
Oca 25
1206
1
Ara 24
1582