[wip] Restringe los productos en purchase.order.line a los productos del proveedor configurado en purchase.order
This commit is contained in:
parent
9c8d61fbac
commit
6a687a878f
4 changed files with 41 additions and 0 deletions
1
purchase_product_restrict_supplier/__init__.py
Normal file
1
purchase_product_restrict_supplier/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from . import models
|
14
purchase_product_restrict_supplier/__manifest__.py
Normal file
14
purchase_product_restrict_supplier/__manifest__.py
Normal 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,
|
||||
}
|
1
purchase_product_restrict_supplier/models/__init__.py
Normal file
1
purchase_product_restrict_supplier/models/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from . import purchase_order_line
|
|
@ -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
|
Loading…
Add table
Reference in a new issue