Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
2194 Näkymät

how to validate a vendor by checking whaether the vendors associated with the product is the vendor given in purchase order in odoo12 community version

please help

Avatar
Hylkää
Paras vastaus

Hai,

from odoo import api, fields, models
from odoo.exceptions import UserError


class VendorValidate(models.Model):
    _inherit = 'purchase.order'
   
    @api.multi
    def _add_supplier_to_product(self) :
        vendor_list=[]
        for order in self:
            for line in order.order_line:
                if order.partner_id.id not in line.product_id.variant_seller_ids.mapped('name.id'):
                    vendor_list.append(line.product_id.name)       
            else:
                 if vendor_list:
                    product_names = ', '.join(vendor_list)
                    raise UserError("Please make sure "+"["+product_names+"]"+" has vendor "+"["+order.partner_id.name+"]")             
 
                I think it works for u..

                Check.

Thanks
             

Avatar
Hylkää
Paras vastaus

Hi,

Write an on-change function for the product in the order lines and check whether the selected vendor is the vendor specified inside the product and do accordingly.


Another option available is to filter the products based on the selected vendor in the purchase order.

Thanks

Avatar
Hylkää