Skip to content

Commit

Permalink
Merge pull request odoo#64 from ingadhoc/add_filter_in_lot
Browse files Browse the repository at this point in the history
ADD filter by ean128 in lots and products
  • Loading branch information
jjscarafia committed Jun 25, 2015
2 parents 30816dd + 588ac8f commit 299d145
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
6 changes: 4 additions & 2 deletions stock_ean128/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
'depends': [
'product_expiry',
],
'data': ['stock_view.xml'
],
'data': [
'stock_view.xml',
'product_view.xml'
],
'demo': [
],
'test': [
Expand Down
25 changes: 24 additions & 1 deletion stock_ean128/product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# -*- coding: utf-8 -*-
from openerp import models, api
from openerp import models, api, fields


class product_template(models.Model):
_inherit = 'product.template'

lot_ids = fields.One2many(
'stock.production.lot',
compute='get_lots',
search='search_lots',
string='Lots'
)

@api.one
def get_lots(self):
return self.env['stock.production.lot'].search(
[('product_id.product_tmpl_id', '=', self.id)])

@api.model
def search_lots(self, operator, operand):
templates = self.env['stock.production.lot'].search(
[('ean_128', operator, operand)]).mapped(
'product_id').mapped('product_tmpl_id')
return [('id', 'in', templates.ids)]


class product_product(models.Model):
Expand Down
18 changes: 18 additions & 0 deletions stock_ean128/product_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_product_template_search" model="ir.ui.view">
<field name="name">product search</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="lot_ids"/>
</field>
</field>
</record>


</data>
</openerp>
18 changes: 15 additions & 3 deletions stock_ean128/stock_view.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_stock_lot_search" model="ir.ui.view">
<field name="name">Stock production lot</field>
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="stock.search_product_lot_filter"/>
<field name="arch" type="xml">
<field name="product_id" position="before">
<field name="ean_128"/>
</field>
</field>
</record>

<record id="view_stock_lot" model="ir.ui.view">
<field name="name">Stock production lot</field>
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_form"/>
<field name="arch" type="xml">
<field name="ref" position="after">
<field name="ean_128"/>
</field>
<field name="ref" position="after">
<field name="ean_128"/>
</field>
</field>
</record>

Expand Down

0 comments on commit 299d145

Please sign in to comment.