Merge lp:~lin-yu/purchase-wkfl/add_purchase_control_suuplier into lp:~purchase-core-editors/purchase-wkfl/7.0

Proposed by LIN Yu
Status: Work in progress
Proposed branch: lp:~lin-yu/purchase-wkfl/add_purchase_control_suuplier
Merge into: lp:~purchase-core-editors/purchase-wkfl/7.0
Diff against target: 224 lines (+195/-0)
5 files modified
purchase_control_supplier/__init__.py (+25/-0)
purchase_control_supplier/__openerp__.py (+46/-0)
purchase_control_supplier/i18n/zh_CN.po (+37/-0)
purchase_control_supplier/purchase.py (+53/-0)
purchase_control_supplier/purchase_view.xml (+34/-0)
To merge this branch: bzr merge lp:~lin-yu/purchase-wkfl/add_purchase_control_suuplier
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Joël Grand-Guillaume @ camptocamp code review, no tests Needs Fixing
Review via email: mp+180795@code.launchpad.net

Description of the change

[ADD] module purchase_supplier_control
* Enables/Disables the supplier control in Purchase.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Lin,

Thanks for the proposal ! A few remarks here:

 * Line 163,170, 179 : please split the lines, too long. You can achieve that using intermediate variable name
  e.g.

product_limit = self.pool.get('res.partner').read(cr,uid,context['supplier_id'],['supplier_product_limit'])['supplier_product_limit']

Can be:

part_obj = self.pool.get('res.partner')
supplier_id = context['supplier_id']
product_limit = part_obj.read(cr,uid,supplier_id,['supplier_product_limit'])

 * Line 166: Any reason not to use the ORM here ? I think you should.

 * Line 179: The help tool tip is confusing for me. Took me a while to get the purpose of the field.. I suggest something more like :

Check that box if you want to only search in products catalog of this supplier when fulfilling a purchase order for him. Otherwise, all products catalog will be available as normal.

 " Line 66: The description of the module should be a bit more precise I think. Refer to the point above to better explaine what "Enables/Disables the supplier control in Purchase" means.

Have a nice day,

Joël

review: Needs Fixing (code review, no tests)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/purchase-workflow. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting

Unmerged revisions

16. By LIN Yu

[ADD] purchase_control_supplier

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'purchase_control_supplier'
2=== added file 'purchase_control_supplier/__init__.py'
3--- purchase_control_supplier/__init__.py 1970-01-01 00:00:00 +0000
4+++ purchase_control_supplier/__init__.py 2013-08-19 07:28:38 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
11+# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+import purchase
29+
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31\ No newline at end of file
32
33=== added file 'purchase_control_supplier/__openerp__.py'
34--- purchase_control_supplier/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ purchase_control_supplier/__openerp__.py 2013-08-19 07:28:38 +0000
36@@ -0,0 +1,46 @@
37+# -*- coding: utf-8 -*-
38+##############################################################################
39+#
40+# OpenERP, Open Source Management Solution
41+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
42+# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
43+#
44+# This program is free software: you can redistribute it and/or modify
45+# it under the terms of the GNU Affero General Public License as
46+# published by the Free Software Foundation, either version 3 of the
47+# License, or (at your option) any later version.
48+#
49+# This program is distributed in the hope that it will be useful,
50+# but WITHOUT ANY WARRANTY; without even the implied warranty of
51+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+# GNU Affero General Public License for more details.
53+#
54+# You should have received a copy of the GNU Affero General Public License
55+# along with this program. If not, see <http://www.gnu.org/licenses/>.
56+#
57+##############################################################################
58+
59+{
60+ 'name': 'Purchase Control Supplier',
61+ 'version': '1.0',
62+ 'category': 'Purchase',
63+ 'sequence': 19,
64+ 'summary': 'Purchase Control Supplier',
65+ 'description': """
66+Enables/Disables the supplier control in Purchase.
67+ """,
68+ 'author': 'Elico Corp',
69+ 'website': 'http://www.elico-corp.com',
70+ 'images' : [],
71+ 'depends': ['purchase'],
72+ 'data': [
73+ 'purchase_view.xml',
74+ ],
75+ 'test': [],
76+ 'demo': [],
77+ 'installable': True,
78+ 'auto_install': False,
79+ 'application': False,
80+}
81+
82+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
83\ No newline at end of file
84
85=== added directory 'purchase_control_supplier/i18n'
86=== added file 'purchase_control_supplier/i18n/zh_CN.po'
87--- purchase_control_supplier/i18n/zh_CN.po 1970-01-01 00:00:00 +0000
88+++ purchase_control_supplier/i18n/zh_CN.po 2013-08-19 07:28:38 +0000
89@@ -0,0 +1,37 @@
90+# Translation of OpenERP Server.
91+# This file contains the translation of the following modules:
92+# * purchase_control_supplier
93+#
94+msgid ""
95+msgstr ""
96+"Project-Id-Version: OpenERP Server 7.0\n"
97+"Report-Msgid-Bugs-To: \n"
98+"POT-Creation-Date: 2013-08-14 09:01+0000\n"
99+"PO-Revision-Date: 2013-08-14 09:01+0000\n"
100+"Last-Translator: <>\n"
101+"Language-Team: \n"
102+"MIME-Version: 1.0\n"
103+"Content-Type: text/plain; charset=UTF-8\n"
104+"Content-Transfer-Encoding: \n"
105+"Plural-Forms: \n"
106+
107+#. module: purchase_control_supplier
108+#: field:res.partner,supplier_product_limit:0
109+msgid "Control Supplier Search"
110+msgstr "Control Supplier Search"
111+
112+#. module: purchase_control_supplier
113+#: model:ir.model,name:purchase_control_supplier.model_res_partner
114+msgid "Partner"
115+msgstr "业务伙伴"
116+
117+#. module: purchase_control_supplier
118+#: model:ir.model,name:purchase_control_supplier.model_product_product
119+msgid "Product"
120+msgstr "产品"
121+
122+#. module: purchase_control_supplier
123+#: help:res.partner,supplier_product_limit:0
124+msgid "If checked, allows you to search only the product in this supplier )"
125+msgstr "If checked, allows you to search only the product in this supplier )"
126+
127
128=== added file 'purchase_control_supplier/purchase.py'
129--- purchase_control_supplier/purchase.py 1970-01-01 00:00:00 +0000
130+++ purchase_control_supplier/purchase.py 2013-08-19 07:28:38 +0000
131@@ -0,0 +1,53 @@
132+# -*- coding: utf-8 -*-
133+##############################################################################
134+#
135+# OpenERP, Open Source Management Solution
136+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
137+# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
138+#
139+# This program is free software: you can redistribute it and/or modify
140+# it under the terms of the GNU Affero General Public License as
141+# published by the Free Software Foundation, either version 3 of the
142+# License, or (at your option) any later version.
143+#
144+# This program is distributed in the hope that it will be useful,
145+# but WITHOUT ANY WARRANTY; without even the implied warranty of
146+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
147+# GNU Affero General Public License for more details.
148+#
149+# You should have received a copy of the GNU Affero General Public License
150+# along with this program. If not, see <http://www.gnu.org/licenses/>.
151+#
152+##############################################################################
153+
154+from osv import osv, fields
155+
156+class product_product(osv.osv):
157+ _name = "product.product"
158+ _inherit = "product.product"
159+
160+ def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
161+
162+ if context and context.get('supplier_id', False):
163+ product_limit = self.pool.get('res.partner').read(cr,uid,context['supplier_id'],['supplier_product_limit'])['supplier_product_limit']
164+ if product_limit:
165+ # ids = []
166+ cr.execute("SELECT distinct(product_id) FROM product_supplierinfo where name = %s" % (context.get('supplier_id')))
167+ ids = [x[0] for x in cr.fetchall()]
168+ args.append(('id', 'in', ids))
169+ order = 'default_code'
170+ return super(product_product, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
171+
172+product_product()
173+
174+class res_partner(osv.osv):
175+ _name = 'res.partner'
176+ _inherit = 'res.partner'
177+
178+ _columns = {
179+ 'supplier_product_limit':fields.boolean("Control Supplier Search", help="""If checked, allows you to search only the product in this supplier )"""),
180+ }
181+
182+ _defaults = {
183+ 'supplier_product_limit': True,
184+ }
185\ No newline at end of file
186
187=== added file 'purchase_control_supplier/purchase_view.xml'
188--- purchase_control_supplier/purchase_view.xml 1970-01-01 00:00:00 +0000
189+++ purchase_control_supplier/purchase_view.xml 2013-08-19 07:28:38 +0000
190@@ -0,0 +1,34 @@
191+<?xml version="1.0" encoding="UTF-8"?>
192+<openerp>
193+ <data>
194+
195+ <record id="view_partner_form_joomla1" model="ir.ui.view">
196+ <field name="name">res.partner.form.FC</field>
197+ <field name="model">res.partner</field>
198+ <field name="type">form</field>
199+ <field name="inherit_id" ref="base.view_partner_form" />
200+ <field name="arch" type="xml">
201+ <xpath expr="//field[@name='customer']" position="after">
202+ <field name="supplier_product_limit" attrs="{'invisible':[('supplier','!=',True)]}"/>
203+ </xpath>
204+ </field>
205+ </record>
206+
207+
208+
209+ <!-- Purchase Order -->
210+ <record id="purchase_order_form_fc" model="ir.ui.view">
211+ <field name="name">purchase.order.form_FC</field>
212+ <field name="model">purchase.order</field>
213+ <field name="type">form</field>
214+ <field name="inherit_id" ref="purchase.purchase_order_form"/>
215+ <field name="arch" type="xml">
216+ <xpath expr="//field[@name='order_line']/tree/field['product_id']" position="replace">
217+
218+ <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" context="{'supplier_id': parent.partner_id}"/>
219+
220+ </xpath>
221+ </field>
222+ </record>
223+ </data>
224+</openerp>

Subscribers

People subscribed via source and target branches