Odoo Help

3 Answers
Faheem Khan
10/12/18, 6:45 AM

I had solved the issue.

The proper code is.

from odoo.exceptions import ValidationError

class ProductTemplateInherit(models.Model):
_inherit = 'product.template'

x_discount = fields.Float(digits=dp.get_precision('Discount'), store=True, readonly=False)

class SaleOrderLineDiscount(models.Model):
_inherit = 'sale.order.line'
x_cotton_qty = fields.Float(string='Cotton Qty', digits=dp.get_precision('Qty'), store=True, readonly=False)
x_pcs_qty = fields.Float(string='PCS Qty', digits=dp.get_precision('Qty'), store=True, readonly=False)

@api.depends('x_cotton_qty', 'x_pcs_qty', 'product_id')
def _comput_from_cotton(self):
for line in self:
line.product_uom_qty = line.x_cotton_qty * line.product_id.uom_po_id.factor_inv + line.x_pcs_qty

product_uom_qty = fields.Float(compute='_comput_from_cotton', string='Quantity',
digits=dp.get_precision('Product Unit of Measure'), required=True, default=1.0)
Ask a Question
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now