Merge lp:~agilebg/purchase-wkfl/imp_product_by_supplier into lp:~purchase-core-editors/purchase-wkfl/7.0

Proposed by Lorenzo Battistini
Status: Superseded
Proposed branch: lp:~agilebg/purchase-wkfl/imp_product_by_supplier
Merge into: lp:~purchase-core-editors/purchase-wkfl/7.0
Diff against target: 195 lines (+125/-16)
2 files modified
product_by_supplier/product.py (+48/-1)
product_by_supplier/product_view.xml (+77/-15)
To merge this branch: bzr merge lp:~agilebg/purchase-wkfl/imp_product_by_supplier
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza code review Approve
Review via email: mp+219017@code.launchpad.net

This proposal has been superseded by a proposal from 2014-07-01.

Description of the change

adding funciotnalities from product_search_reference.
Now it's possible to search products everywhere by supplier code

In the rev. 34 I merged https://code.launchpad.net/~agilebg/purchase-wkfl/fix_1335153 useful to fix the following bug: https://bugs.launchpad.net/purchase-wkfl/+bug/1335153

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Lorenzo, thanks for expanding this module.

I see a possible problem giving more priority to partner search than to any other, because you make a return in case that there are ids in this search. I think you must join all results to allow for example "Search more..." option to appear.

Regards.

review: Needs Information (code review)
33. By Lorenzo Battistini

[IMP] join all results to allow for example "Search more..." option to appear

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello Pedro,
just modified the name_search.
Thanks

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Thanks for the changes.

Regards.

review: Approve (code review)
34. By Alex Comba - Agile BG

[MRG] Merged lp:~agilebg/purchase-wkfl/fix_1335153

35. By Lorenzo Battistini

[FIX] without this change, the _partner_ref2_search method only works when template ID == product ID

36. By Lorenzo Battistini

[IMP] PEP8

37. By Hurrinico

[FIX] lep's fixing

Unmerged revisions

37. By Hurrinico

[FIX] lep's fixing

36. By Lorenzo Battistini

[IMP] PEP8

35. By Lorenzo Battistini

[FIX] without this change, the _partner_ref2_search method only works when template ID == product ID

34. By Alex Comba - Agile BG

[MRG] Merged lp:~agilebg/purchase-wkfl/fix_1335153

33. By Lorenzo Battistini

[IMP] join all results to allow for example "Search more..." option to appear

32. By Lorenzo Battistini

[IMP] product_by_supplier adding funciotnalities from product_search_reference.
Now it's possible to search products everywhere by supplier code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product_by_supplier/product.py'
2--- product_by_supplier/product.py 2014-04-24 14:26:27 +0000
3+++ product_by_supplier/product.py 2014-07-01 16:33:41 +0000
4@@ -2,6 +2,7 @@
5 ##############################################################################
6 #
7 # OpenERP, Open Source Management Solution
8+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
9 # Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
10 # Author: Yannick Gouin <yannick.gouin@elico-corp.com>
11 #
12@@ -56,4 +57,50 @@
13 ),
14 }
15
16-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
17+
18+class product_product(orm.Model):
19+ _inherit = 'product.product'
20+
21+ def _partner_ref2(self, cr, user, ids, name, arg, context=None):
22+ res = {}
23+ for product in self.browse(cr, user, ids, context=context):
24+ res[product.id] = '\n'.join(
25+ [x.product_code for x in product.seller_ids if x.product_code]
26+ ) or ''
27+ return res
28+
29+ def _partner_ref2_search(self, cr, user, obj, name, args, context={}):
30+ supplierinfo_obj = self.pool.get('product.supplierinfo')
31+ args = args[:]
32+ i = 0
33+ while i < len(args):
34+ args[i] = ('product_code', args[i][1], args[i][2])
35+ i += 1
36+ supplierinfo_ids = supplierinfo_obj.search(cr, user, args)
37+ product_ids = [x.product_id.id for x in supplierinfo_obj.browse(
38+ cr, user,
39+ supplierinfo_ids) if x.product_id]
40+ return [('id', 'in', product_ids)]
41+
42+ _columns = {
43+ 'partner_ref2': fields.function(
44+ _partner_ref2, method=True,
45+ type='char', string='Supplier codes',
46+ fnct_search=_partner_ref2_search),
47+ }
48+
49+ def name_search(
50+ self, cr, user, name='', args=None, operator='ilike',
51+ context=None, limit=80):
52+ main_results = super(product_product, self).name_search(
53+ cr, user, name=name, args=args,
54+ operator=operator, context=context, limit=limit)
55+ ids = self.search(
56+ cr, user, [('partner_ref2', '=', name)] + args,
57+ limit=limit, context=context)
58+ if ids:
59+ supplier_results = self.name_get(cr, user, ids, context=context)
60+ for supplier_result in supplier_results:
61+ if supplier_result not in main_results:
62+ main_results.append(supplier_result)
63+ return main_results
64
65=== modified file 'product_by_supplier/product_view.xml'
66--- product_by_supplier/product_view.xml 2014-04-28 09:22:50 +0000
67+++ product_by_supplier/product_view.xml 2014-07-01 16:33:41 +0000
68@@ -1,6 +1,9 @@
69 <?xml version="1.0" encoding="UTF-8"?>
70 <openerp>
71 <data>
72+
73+ <!-- Supplier info -->
74+
75 <record id="view_product_supplierinfo_search" model="ir.ui.view">
76 <field name="name">product.supplierinfo.search</field>
77 <field name="model">product.supplierinfo</field>
78@@ -22,8 +25,42 @@
79 </field>
80 </record>
81
82- <record id="view_product_supplierinfo_tree1" model="ir.ui.view">
83- <field name="name">product.supplierinfo.tree1</field>
84+ <record id="view_product_supplierinfo_form" model="ir.ui.view">
85+ <field name="name">product.supplierinfo.form</field>
86+ <field name="model">product.supplierinfo</field>
87+ <field name="priority">99</field>
88+ <field name="arch" type="xml">
89+ <form string="Supplier Information" version="7.0">
90+ <group col="4">
91+ <field name="name" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"/>
92+ <field name="product_id"/>
93+ <field name="sequence"/>
94+ <field name="product_name"/>
95+ <field name="product_code"/>
96+ <field name="min_qty"/>
97+ <field name="product_uom" groups="product.group_uom"/>
98+ <field name="delay"/>
99+ <field name="company_id" groups="base.group_multi_company" widget="selection"/>
100+ </group>
101+ <p groups="product.group_purchase_pricelist" class="oe_grey">The prices below will only be taken into account when your pricelist is set as based on supplier prices.</p>
102+ <field groups="product.group_purchase_pricelist" name="pricelist_ids">
103+ <tree editable="bottom" string="Pricelist">
104+ <field name="min_quantity"/>
105+ <field name="price"/>
106+ </tree>
107+ <form version="7.0">
108+ <group>
109+ <field name="min_quantity"/>
110+ <field name="price"/>
111+ </group>
112+ </form>
113+ </field>
114+ </form>
115+ </field>
116+ </record>
117+
118+ <record id="view_product_supplierinfo_tree" model="ir.ui.view">
119+ <field name="name">product.supplierinfo.tree</field>
120 <field name="model">product.supplierinfo</field>
121 <field name="priority">90</field>
122 <field name="arch" type="xml">
123@@ -42,34 +79,59 @@
124 </field>
125 </record>
126
127- <record id="view_product_supplierinfo_form1" model="ir.ui.view">
128- <field name="name">product.supplierinfo.form1</field>
129- <field name="model">product.supplierinfo</field>
130- <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
131- <field name="priority">99</field>
132- <field name="arch" type="xml">
133- <xpath expr="//field[@name='sequence']" position="before">
134- <field name="product_id"/>
135- </xpath>
136- </field>
137- </record>
138-
139 <record id="action_product_supplier_info" model="ir.actions.act_window">
140 <field name="name">Product by Suppliers</field>
141 <field name="res_model">product.supplierinfo</field>
142 <field name="type">ir.actions.act_window</field>
143 <field name="view_type">form</field>
144 <field name="view_mode">tree,form</field>
145- <field name="view_id" ref="view_product_supplierinfo_tree1"/>
146 <field name="search_view_id" ref="view_product_supplierinfo_search"/>
147 <field name="context">{'search_default_supplier':1,'group_by':[]}</field>
148 </record>
149
150+ <record id="action_product_supplierinfo_form" model="ir.actions.act_window.view">
151+ <field eval="2" name="sequence"/>
152+ <field name="view_mode">form</field>
153+ <field name="view_id" ref="view_product_supplierinfo_form" />
154+ <field name="act_window_id" ref="action_product_supplier_info" />
155+ </record>
156+
157+ <record id="action_product_supplierinfo_tree" model="ir.actions.act_window.view">
158+ <field eval="1" name="sequence"/>
159+ <field name="view_mode">tree</field>
160+ <field name="view_id" ref="view_product_supplierinfo_tree" />
161+ <field name="act_window_id" ref="action_product_supplier_info" />
162+ </record>
163 <menuitem
164 id="menu_product_supplier_info"
165 name="Product by Suppliers"
166 sequence="15"
167 action="action_product_supplier_info"
168 parent="purchase.menu_procurement_management_product"/>
169+
170+ <!-- Product -->
171+
172+ <record model="ir.ui.view" id="product_product_tree_view_inherit">
173+ <field name="name">product.product.tree.inherit</field>
174+ <field name="model">product.product</field>
175+ <field name="inherit_id" ref="product.product_product_tree_view"/>
176+ <field name="arch" type="xml">
177+ <field name="state" position="before">
178+ <field name="partner_ref2"/>
179+ </field>
180+ </field>
181+ </record>
182+
183+ <record model="ir.ui.view" id="product_search_form_view">
184+ <field name="name">product_search_form_view</field>
185+ <field name="model">product.product</field>
186+ <field name="inherit_id" ref="product.product_search_form_view"/>
187+ <field name="arch" type="xml">
188+ <field name="name" position="after">
189+ <field name="partner_ref2"/>
190+ </field>
191+ </field>
192+ </record>
193+
194 </data>
195 </openerp>

Subscribers

People subscribed via source and target branches