[wip] Restringe los productos en purchase.order.line a los productos del proveedor configurado en purchase.order

This commit is contained in:
santiky 2021-09-02 16:50:06 +02:00
parent 9c8d61fbac
commit 6a687a878f
Signed by: snt
GPG key ID: A9FD34930EADBE71
4 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,14 @@
# Copyright 2021 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Purchase Product Restrict Supplier',
'summary': 'It restricts products in purchase order line belonging to the partner set in purchase order.',
'version': '12.0.1.0.1',
'author': 'Criptomart',
'depends': [
'purchase',
],
'installable': True,
'auto_install': False,
'application': False,
}

View file

@ -0,0 +1 @@
from . import purchase_order_line

View file

@ -0,0 +1,25 @@
# Copyright (C) 2021: Criptomart (<https://criptomart.net/>)
# @author: Criptomart (<tech@criptomart.net>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo import models, fields, api
_logger = logging.getLogger(__name__)
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
@api.multi
def onchange_product_id(self):
_logger.warning("begin onchange_product_id")
result = super(PurchaseOrderLine, self).onchange_product_id()
supplier_infos = self.env['product.supplierinfo'].search([('name', '=', self.partner_id.comercial)])
product_ids = self.env['product.product']
for supplier_info in supplier_infos:
product_ids += supplier_info.product_tmpl_id.product_variant_ids
result.update({'domain': {'product_id': [('id', 'in', product_ids.ids)]}})
return result