Merge lp:~lin-yu/purchase-wkfl/add_purchase_po_price 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_po_price
Merge into: lp:~purchase-core-editors/purchase-wkfl/7.0
Diff against target: 364 lines (+335/-0)
5 files modified
purchase_po_price/__init__.py (+23/-0)
purchase_po_price/__openerp__.py (+42/-0)
purchase_po_price/i18n/zh_CN.po (+89/-0)
purchase_po_price/purchase.py (+113/-0)
purchase_po_price/purchase_view.xml (+68/-0)
To merge this branch: bzr merge lp:~lin-yu/purchase-wkfl/add_purchase_po_price
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Joël Grand-Guillaume @ camptocamp code review, functionnal Needs Information
Review via email: mp+180792@code.launchpad.net

Description of the change

[ADD] Purchase PO Price Control Module
        * Enable/Disable control on PO Price

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 contribution ! A got some stuff I'm not sure about in this module.

1) The description only mention "Enable/Disable control on PO Price" it's a bit too short.

2) Lots of other fields (I mean not related to the control of price) is present on PO Line, like qty_received, qty_unreceived,.. Those field do not seems to me related to the purpose of the module.. I don't actually know if it really make sens to have them here. Any pointer ?

3) Field like modify_price do not seems to be used, sequence serve another purpose than the one I see in this module

What I suggest is that you firstly make a better explanation of the purpose and use of the module. Once done, we can discuss further on what to let in there and what not. On my own opinion, this module should only forbid to change the price in PO if not allowed for this supplier.

Best regards,

review: Needs Information (code review, functionnal)
Revision history for this message
LIN Yu (lin-yu) wrote :

Dear Joël,
Thanks for your reply.
I will work on it and make it more clear.

BR,
On 09/11/2013 10:57 PM, Joël Grand-Guillaume @ camptocamp wrote:
> Review: Needs Information code review, functionnal
>
> Hi Lin,
>
> Thanks for the contribution ! A got some stuff I'm not sure about in this module.
>
> 1) The description only mention "Enable/Disable control on PO Price" it's a bit too short.
>
> 2) Lots of other fields (I mean not related to the control of price) is present on PO Line, like qty_received, qty_unreceived,.. Those field do not seems to me related to the purpose of the module.. I don't actually know if it really make sens to have them here. Any pointer ?
>
> 3) Field like modify_price do not seems to be used, sequence serve another purpose than the one I see in this module
>
> What I suggest is that you firstly make a better explanation of the purpose and use of the module. Once done, we can discuss further on what to let in there and what not. On my own opinion, this module should only forbid to change the price in PO if not allowed for this supplier.
>
> Best regards,
>
>

--
LIN Yu

LIN Yu
/Project Manager/
--
*Elico Corporation, Shanghai
/OpenERP Premium Certified Training Partner/ *
Cell: + 86 186 1691 1351
Office: + 86 21 6211 8017/27
Skype: llccluf
<email address hidden> <mailto:<email address hidden>>
http://www.elico-corp.com

Elico Corp

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> Dear Joël,
> Thanks for your reply.
> I will work on it and make it more clear.
>
> BR,

Hi,

So I change your proposal to 'work in progress'. Please set it back to 'Needs review' when you are done.

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_po_price

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'purchase_po_price'
2=== added file 'purchase_po_price/__init__.py'
3--- purchase_po_price/__init__.py 1970-01-01 00:00:00 +0000
4+++ purchase_po_price/__init__.py 2013-08-19 07:16:14 +0000
5@@ -0,0 +1,23 @@
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\ No newline at end of file
30
31=== added file 'purchase_po_price/__openerp__.py'
32--- purchase_po_price/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ purchase_po_price/__openerp__.py 2013-08-19 07:16:14 +0000
34@@ -0,0 +1,42 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# OpenERP, Open Source Management Solution
39+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
40+# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+
57+{
58+ 'name': 'Purchase PO Price',
59+ 'version': '1.0',
60+ 'category': 'Purchase',
61+ 'sequence': 19,
62+ 'summary': 'Purchase PO Price',
63+ 'description': """ Enable/Disable control on PO Price """,
64+ 'author': 'Elico Corp',
65+ 'website': 'http://www.elico-corp.com',
66+ 'images' : [],
67+ 'depends': ['purchase'],
68+ 'data': [
69+ 'purchase_view.xml',
70+ ],
71+ 'test': [],
72+ 'demo': [],
73+ 'installable': True,
74+ 'auto_install': False,
75+ 'application': False,
76+}
77\ No newline at end of file
78
79=== added directory 'purchase_po_price/i18n'
80=== added file 'purchase_po_price/i18n/zh_CN.po'
81--- purchase_po_price/i18n/zh_CN.po 1970-01-01 00:00:00 +0000
82+++ purchase_po_price/i18n/zh_CN.po 2013-08-19 07:16:14 +0000
83@@ -0,0 +1,89 @@
84+# Translation of OpenERP Server.
85+# This file contains the translation of the following modules:
86+# * purchase_po_price
87+#
88+msgid ""
89+msgstr ""
90+"Project-Id-Version: OpenERP Server 7.0\n"
91+"Report-Msgid-Bugs-To: \n"
92+"POT-Creation-Date: 2013-08-14 09:02+0000\n"
93+"PO-Revision-Date: 2013-08-14 09:02+0000\n"
94+"Last-Translator: <>\n"
95+"Language-Team: \n"
96+"MIME-Version: 1.0\n"
97+"Content-Type: text/plain; charset=UTF-8\n"
98+"Content-Transfer-Encoding: \n"
99+"Plural-Forms: \n"
100+
101+#. module: purchase_po_price
102+#: code:addons/purchase_po_price/purchase.py:105
103+#, python-format
104+msgid "You can not modify the price of this product sold by this supplier !"
105+msgstr "You can not modify the price of this product sold by this supplier !"
106+
107+#. module: purchase_po_price
108+#: model:ir.model,name:purchase_po_price.model_purchase_order_line
109+msgid "Purchase Order Line"
110+msgstr "采购订单明细"
111+
112+#. module: purchase_po_price
113+#: field:purchase.order.line,amount_subtotal:0
114+msgid "Subtotal(Inc. Tax)"
115+msgstr "小计(含税)"
116+
117+#. module: purchase_po_price
118+#: field:purchase.order.line,modify_price:0
119+msgid "Modify Price"
120+msgstr "修改价格"
121+
122+#. module: purchase_po_price
123+#: field:purchase.order.line,qty_received:0
124+msgid "Reception Qty"
125+msgstr "已收货数量"
126+
127+#. module: purchase_po_price
128+#: field:purchase.order.line,sequence:0
129+msgid "Sequence"
130+msgstr "序号"
131+
132+#. module: purchase_po_price
133+#: code:addons/purchase_po_price/purchase.py:105
134+#, python-format
135+msgid "PO Price"
136+msgstr "PO Price"
137+
138+#. module: purchase_po_price
139+#: field:purchase.order.line,qty_unreceived:0
140+msgid "Waiting Qty"
141+msgstr "待收货数量"
142+
143+#. module: purchase_po_price
144+#: view:purchase.order:0
145+msgid "Purchase Order Lines"
146+msgstr "采购订单明细"
147+
148+#. module: purchase_po_price
149+#: field:purchase.order.line,price_unit_original:0
150+msgid "Original Unit Price"
151+msgstr "原始单价"
152+
153+#. module: purchase_po_price
154+#: model:ir.model,name:purchase_po_price.model_res_partner
155+msgid "Partner"
156+msgstr "业务伙伴"
157+
158+#. module: purchase_po_price
159+#: help:res.partner,po_price_modification_limit:0
160+msgid "If checked, allows you to change the price in PO (only when either the Supplier or Product allow it)"
161+msgstr "若选择, 允许你在采购上修改单价(在供应商或者产品上设置一个即可)"
162+
163+#. module: purchase_po_price
164+#: help:purchase.order.line,sequence:0
165+msgid "Sequence for order in view and print report"
166+msgstr "用于视图和报表中的序号"
167+
168+#. module: purchase_po_price
169+#: field:res.partner,po_price_modification_limit:0
170+msgid "No control on PO price"
171+msgstr "不控采购单价"
172+
173
174=== added file 'purchase_po_price/purchase.py'
175--- purchase_po_price/purchase.py 1970-01-01 00:00:00 +0000
176+++ purchase_po_price/purchase.py 2013-08-19 07:16:14 +0000
177@@ -0,0 +1,113 @@
178+# -*- coding: utf-8 -*-
179+##############################################################################
180+#
181+# OpenERP, Open Source Management Solution
182+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
183+# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
184+#
185+# This program is free software: you can redistribute it and/or modify
186+# it under the terms of the GNU Affero General Public License as
187+# published by the Free Software Foundation, either version 3 of the
188+# License, or (at your option) any later version.
189+#
190+# This program is distributed in the hope that it will be useful,
191+# but WITHOUT ANY WARRANTY; without even the implied warranty of
192+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
193+# GNU Affero General Public License for more details.
194+#
195+# You should have received a copy of the GNU Affero General Public License
196+# along with this program. If not, see <http://www.gnu.org/licenses/>.
197+#
198+##############################################################################
199+
200+from osv import osv, fields
201+from tools.translate import _
202+import openerp.addons.decimal_precision as dp
203+
204+class res_partner(osv.osv):
205+ _name = 'res.partner'
206+ _inherit = 'res.partner'
207+
208+ _columns = {
209+ 'po_price_modification_limit':fields.boolean("No control on PO price", help="""If checked, allows you to change the price in PO (only when either the Supplier or Product allow it)"""),
210+ }
211+
212+ _defaults = {
213+ 'po_price_modification_limit': True,
214+ }
215+res_partner()
216+
217+class purchase_order_line(osv.osv):
218+ _inherit = 'purchase.order.line'
219+
220+ _order = 'order_id desc, sequence'
221+
222+ def _amount_line_with_tax(self, cr, uid, ids, prop, arg, context=None):
223+ res = {}
224+ cur_obj = self.pool.get('res.currency')
225+ tax_obj = self.pool.get('account.tax')
226+ for line in self.browse(cr, uid, ids, context=context):
227+ taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id, line.order_id.partner_id, force_excluded=True)
228+ cur = line.order_id.pricelist_id.currency_id
229+ res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
230+ return res
231+
232+ def _qty_received(self, cr, uid, ids, prop, arg, context=None):
233+ res = {}
234+ for line in self.browse(cr, uid, ids, context=context):
235+ qty = 0.0
236+ for move in line.move_ids:
237+ if move.state == 'done':
238+ qty += move.product_qty
239+ res[line.id] = qty
240+ return res
241+
242+ def _qty_unreceived(self, cr, uid, ids, prop, arg, context=None):
243+ res = {}
244+ for line in self.browse(cr, uid, ids, context=context):
245+ qty = 0.0
246+ for move in line.move_ids:
247+ if move.state not in ('done', 'cancel'):
248+ qty += move.product_qty
249+ res[line.id] = qty
250+ return res
251+
252+ _columns = {
253+ 'modify_price': fields.boolean('Modify Price'),
254+ 'sequence': fields.integer('Sequence', help="Sequence for order in view and print report"),
255+ 'amount_subtotal': fields.function(_amount_line_with_tax, string='Subtotal(Inc. Tax)', type='float', digits_compute=dp.get_precision('Account')),
256+ 'qty_received': fields.function(_qty_received, string='Reception Qty', type='float', digits_compute=dp.get_precision('Product Unit of Measure')),
257+ 'qty_unreceived': fields.function(_qty_unreceived, string='Waiting Qty', type='float', digits_compute=dp.get_precision('Product Unit of Measure')),
258+ 'price_unit_original': fields.float('Original Unit Price', digits_compute=dp.get_precision('Product Price')),
259+ #'price_unit_exclude_tax': fields.function(_price_unit_line_without_tax, string='Unit Price(Exc. Tax)', type='float', digits_compute=dp.get_precision('Product Price')),
260+ }
261+ _defaults = {
262+ 'sequence': 1,
263+ 'modify_price': False,
264+ }
265+
266+
267+ def onchange_price_unit(self, cr, uid, ids, partner_id, product_id, price_unit_original, price_unit, context=None):
268+ #Not use at the moment! add a readonly attribute in view definition!
269+ context = context or {}
270+ res = {}
271+
272+ if not partner_id and not product_id:
273+ return res
274+ product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
275+ partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
276+
277+ #if purchase_config_settings.po_price_modification_limit:
278+ #if not product.po_price_modification_limit and not partner.po_price_modification_limit and price_unit_original != price_unit:
279+ if not partner.po_price_modification_limit:
280+
281+ res['value'] = {'price_unit': price_unit_original}
282+ res['warning'] = {'title' : _('PO Price'), 'message' : _('You can not modify the price of this product sold by this supplier !')}
283+ #raise osv.except_osv(_('Error!'), _('You can not modify the price of this product sold by this supplier !'))
284+ else:
285+ res['value'] = {'price_unit_original':price_unit}
286+ #ENDIF
287+
288+ return res
289+
290+purchase_order_line()
291
292=== added file 'purchase_po_price/purchase_view.xml'
293--- purchase_po_price/purchase_view.xml 1970-01-01 00:00:00 +0000
294+++ purchase_po_price/purchase_view.xml 2013-08-19 07:16:14 +0000
295@@ -0,0 +1,68 @@
296+<?xml version="1.0" encoding="UTF-8"?>
297+<openerp>
298+ <data>
299+
300+ <record id="view_partner_form_joomla" model="ir.ui.view">
301+ <field name="name">res.partner.form.FC</field>
302+ <field name="model">res.partner</field>
303+ <field name="type">form</field>
304+ <field name="inherit_id" ref="base.view_partner_form" />
305+ <field name="arch" type="xml">
306+ <xpath expr="//field[@name='customer']" position="after">
307+
308+ <field name="po_price_modification_limit" attrs="{'invisible':[('supplier','!=',True)]}"/>
309+
310+ <!-- <field name="supplier_product_limit" attrs="{'invisible':[('supplier','!=',True)]}"/> -->
311+
312+ </xpath>
313+ </field>
314+ </record>
315+
316+ <!-- <record id="product_normal_form_view_FC" model="ir.ui.view">
317+ <field name="name">product.normal.form.FC</field>
318+ <field name="model">product.product</field>
319+ <field name="type">form</field>
320+ <field name="inherit_id" ref="product.product_normal_form_view" />
321+ <field name="arch" type="xml">
322+ <xpath expr="//field[@name='uom_po_id']" position="after">
323+ <field name="po_price_modification_limit"/>
324+ </xpath>
325+ </field>
326+ </record> -->
327+
328+ <!-- Purchase Order -->
329+ <record id="purchase_order_form_fc" model="ir.ui.view">
330+ <field name="name">purchase.order.form_FC</field>
331+ <field name="model">purchase.order</field>
332+ <field name="type">form</field>
333+ <field name="inherit_id" ref="purchase.purchase_order_form"/>
334+ <field name="arch" type="xml">
335+ <xpath expr="//field[@name='order_line']" position="replace">
336+ <field name="order_line">
337+ <tree string="Purchase Order Lines" editable="bottom">
338+
339+ <!-- field name="sequence"/>< by Andy-->
340+ <field name="modify_price" invisible="1"/>
341+ <!-- <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}"/> -->
342+ <field name="name"/>
343+ <field name="date_planned"/>
344+ <field name="company_id" groups="base.group_multi_company" widget="selection"/>
345+ <field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('parent_id','!=',False)]"/>
346+ <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
347+ <field name="product_uom" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
348+ <!--field name="price_unit" attrs="{'readonly':[('modify_price','=',True)]}"/-->
349+ <field name="price_unit_original" invisible="1"/>
350+ <field name="price_unit" on_change="onchange_price_unit(parent.partner_id,product_id,price_unit_original,price_unit,context)"/>
351+ <field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
352+ <!-- <field name="price_unit_exclude_tax"/> -->
353+ <field name="price_subtotal" invisible="1"/>
354+ <field name="amount_subtotal"/><!-- by Andy-->
355+
356+ </tree>
357+ </field>
358+ </xpath>
359+ </field>
360+ </record>
361+
362+ </data>
363+</openerp>
364\ No newline at end of file

Subscribers

People subscribed via source and target branches