port to 17.0 suppliler code search
This commit is contained in:
parent
4815b71c5f
commit
722b8cef8a
5 changed files with 68 additions and 0 deletions
5
bemade_search_supplier_code/__init__.py
Normal file
5
bemade_search_supplier_code/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
24
bemade_search_supplier_code/__manifest__.py
Normal file
24
bemade_search_supplier_code/__manifest__.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
'name': 'Search Supplier Code',
|
||||||
|
'version': '17.0.0.1',
|
||||||
|
'summary': 'Search for products by supplier code',
|
||||||
|
'sequence': 10,
|
||||||
|
'description': """
|
||||||
|
This module adds the ability to search for products by supplier code.
|
||||||
|
""",
|
||||||
|
'category': 'Inventory/Purchase',
|
||||||
|
'author': 'Bemade',
|
||||||
|
'website': 'https://www.bemade.org',
|
||||||
|
'depends': [
|
||||||
|
'purchase',
|
||||||
|
'product'
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/product_product_views.xml',
|
||||||
|
],
|
||||||
|
'demo': [],
|
||||||
|
'installable': True,
|
||||||
|
'application': False,
|
||||||
|
'auto_install': False,
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
}
|
||||||
1
bemade_search_supplier_code/models/__init__.py
Normal file
1
bemade_search_supplier_code/models/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import product_product
|
||||||
26
bemade_search_supplier_code/models/product_product.py
Normal file
26
bemade_search_supplier_code/models/product_product.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
|
class ProductProduct(models.Model):
|
||||||
|
_inherit = 'product.product'
|
||||||
|
|
||||||
|
supplier_codes = fields.Char(
|
||||||
|
compute='_compute_supplier_codes',
|
||||||
|
string='Supplier Codes',
|
||||||
|
store=True,
|
||||||
|
search='_search_supplier_codes')
|
||||||
|
|
||||||
|
@api.depends('variant_seller_ids', 'variant_seller_ids.product_code')
|
||||||
|
def _compute_supplier_codes(self):
|
||||||
|
for product in self:
|
||||||
|
codes = filter(lambda x: isinstance(x, str), product.variant_seller_ids.mapped('product_code'))
|
||||||
|
product.supplier_codes = ', '.join(codes)
|
||||||
|
|
||||||
|
def _search_supplier_codes(self, operator, value):
|
||||||
|
if not value:
|
||||||
|
return []
|
||||||
|
|
||||||
|
supplierinfo_ids = self.env['product.supplierinfo'].search([('product_code', operator, value)])
|
||||||
|
product_ids = supplierinfo_ids.mapped('product_id.id')
|
||||||
|
|
||||||
|
return [('id', 'in', product_ids)]
|
||||||
12
bemade_search_supplier_code/views/product_product_views.xml
Normal file
12
bemade_search_supplier_code/views/product_product_views.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<odoo>
|
||||||
|
<record id="view_product_product_search" model="ir.ui.view">
|
||||||
|
<field name="name">product.product.search.inherit</field>
|
||||||
|
<field name="model">product.product</field>
|
||||||
|
<field name="inherit_id" ref="product.product_search_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="name" position="after">
|
||||||
|
<field name="supplier_codes"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in a new issue