Hi everyone, iam using odoo14 community version, i want to create a field in odoo purchase order line where it shows me the difference between the quantity and received product in order lines for each product
eg: i want to show quantity - received qty = remaining qty for each products in purchase order line, how can i achieve this using python or xml
Thank you
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
Hello, the mistake you are doing is that you are inheriting purchase.order.line and then trying to again get orderline field in this object which is in purchase order. So the correct code for the method would be something like this and rest what you have coded as it is:
@api.depends('product_qty', 'qty_received',)
def _compute_x_grand_total(self):
for record in self:
record.x_grand_total = record.product_qty - record.qty_received
Thank you @Abhinav Vaidya this solved my problem
Hi Jo,
Your calculation is correct,but no need to give dependency 'order_line' here,because you have written the computation inside ' purchase.order.line' model.So just remove that dependancy and try.
Hope it will help you.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
1
janv. 22
|
2486 | ||
|
0
juin 21
|
2964 | ||
|
3
févr. 24
|
4879 | ||
|
2
oct. 23
|
3091 | ||
|
1
avr. 23
|
3691 |
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class PurchaseOrderComputeField(models.Model):
_inherit = "purchase.order.line"
x_grand_total = fields.Float(compute='_compute_x_grand_total', string='Remaining Quantity')
@api.depends('order_line')
def _compute_x_grand_total(self):
for record in self:
record.x_grand_total = record.product_qty - record.qty_received
This is the code i am using
i am getting this error :
ValueError: Field purchase.order.line.x_grand_total cannot find dependency 'order_line' on model 'purchase.order.line'.
What am i doing wrong