I'm very new on ODOO. I'm trying to validate the purchase orders VS a custom field (quantity permited by certain supplier).
I've created a module with the following:
models.py
from odoo import models, fields, api
class SupplierInfoInherited(models.Model):
_inherit = 'product.supplierinfo'
quantity = fields.Integer(string='Quantity allowed for this supplier')
On view.xml:
<odoo>
<!--Inherit the supplier form view-->
<record id="view_supplier_form_custom" model="ir.ui.view">
<field name="name">product.supplierinfo.form.inherited</field>
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="quantity"/>
</xpath>
</field>
</record>
Now i'm need get this value on purchases.order.line and validate that the quantity of products does not exceed the amount determined in the custom rule, using javascript/python at the moment of purchase. Any ideas? thanks