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
=== added directory 'purchase_po_price'
=== added file 'purchase_po_price/__init__.py'
--- purchase_po_price/__init__.py 1970-01-01 00:00:00 +0000
+++ purchase_po_price/__init__.py 2013-08-19 07:16:14 +0000
@@ -0,0 +1,23 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
6# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import purchase
0\ No newline at end of file24\ No newline at end of file
125
=== added file 'purchase_po_price/__openerp__.py'
--- purchase_po_price/__openerp__.py 1970-01-01 00:00:00 +0000
+++ purchase_po_price/__openerp__.py 2013-08-19 07:16:14 +0000
@@ -0,0 +1,42 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
6# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23{
24 'name': 'Purchase PO Price',
25 'version': '1.0',
26 'category': 'Purchase',
27 'sequence': 19,
28 'summary': 'Purchase PO Price',
29 'description': """ Enable/Disable control on PO Price """,
30 'author': 'Elico Corp',
31 'website': 'http://www.elico-corp.com',
32 'images' : [],
33 'depends': ['purchase'],
34 'data': [
35 'purchase_view.xml',
36 ],
37 'test': [],
38 'demo': [],
39 'installable': True,
40 'auto_install': False,
41 'application': False,
42}
0\ No newline at end of file43\ No newline at end of file
144
=== added directory 'purchase_po_price/i18n'
=== added file 'purchase_po_price/i18n/zh_CN.po'
--- purchase_po_price/i18n/zh_CN.po 1970-01-01 00:00:00 +0000
+++ purchase_po_price/i18n/zh_CN.po 2013-08-19 07:16:14 +0000
@@ -0,0 +1,89 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * purchase_po_price
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-08-14 09:02+0000\n"
10"PO-Revision-Date: 2013-08-14 09:02+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: purchase_po_price
19#: code:addons/purchase_po_price/purchase.py:105
20#, python-format
21msgid "You can not modify the price of this product sold by this supplier !"
22msgstr "You can not modify the price of this product sold by this supplier !"
23
24#. module: purchase_po_price
25#: model:ir.model,name:purchase_po_price.model_purchase_order_line
26msgid "Purchase Order Line"
27msgstr "采购订单明细"
28
29#. module: purchase_po_price
30#: field:purchase.order.line,amount_subtotal:0
31msgid "Subtotal(Inc. Tax)"
32msgstr "小计(含税)"
33
34#. module: purchase_po_price
35#: field:purchase.order.line,modify_price:0
36msgid "Modify Price"
37msgstr "修改价格"
38
39#. module: purchase_po_price
40#: field:purchase.order.line,qty_received:0
41msgid "Reception Qty"
42msgstr "已收货数量"
43
44#. module: purchase_po_price
45#: field:purchase.order.line,sequence:0
46msgid "Sequence"
47msgstr "序号"
48
49#. module: purchase_po_price
50#: code:addons/purchase_po_price/purchase.py:105
51#, python-format
52msgid "PO Price"
53msgstr "PO Price"
54
55#. module: purchase_po_price
56#: field:purchase.order.line,qty_unreceived:0
57msgid "Waiting Qty"
58msgstr "待收货数量"
59
60#. module: purchase_po_price
61#: view:purchase.order:0
62msgid "Purchase Order Lines"
63msgstr "采购订单明细"
64
65#. module: purchase_po_price
66#: field:purchase.order.line,price_unit_original:0
67msgid "Original Unit Price"
68msgstr "原始单价"
69
70#. module: purchase_po_price
71#: model:ir.model,name:purchase_po_price.model_res_partner
72msgid "Partner"
73msgstr "业务伙伴"
74
75#. module: purchase_po_price
76#: help:res.partner,po_price_modification_limit:0
77msgid "If checked, allows you to change the price in PO (only when either the Supplier or Product allow it)"
78msgstr "若选择, 允许你在采购上修改单价(在供应商或者产品上设置一个即可)"
79
80#. module: purchase_po_price
81#: help:purchase.order.line,sequence:0
82msgid "Sequence for order in view and print report"
83msgstr "用于视图和报表中的序号"
84
85#. module: purchase_po_price
86#: field:res.partner,po_price_modification_limit:0
87msgid "No control on PO price"
88msgstr "不控采购单价"
89
090
=== added file 'purchase_po_price/purchase.py'
--- purchase_po_price/purchase.py 1970-01-01 00:00:00 +0000
+++ purchase_po_price/purchase.py 2013-08-19 07:16:14 +0000
@@ -0,0 +1,113 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
6# Author: Jean LELIEVRE <jean.lelievre@elico-corp.com>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from osv import osv, fields
24from tools.translate import _
25import openerp.addons.decimal_precision as dp
26
27class res_partner(osv.osv):
28 _name = 'res.partner'
29 _inherit = 'res.partner'
30
31 _columns = {
32 '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)"""),
33 }
34
35 _defaults = {
36 'po_price_modification_limit': True,
37 }
38res_partner()
39
40class purchase_order_line(osv.osv):
41 _inherit = 'purchase.order.line'
42
43 _order = 'order_id desc, sequence'
44
45 def _amount_line_with_tax(self, cr, uid, ids, prop, arg, context=None):
46 res = {}
47 cur_obj = self.pool.get('res.currency')
48 tax_obj = self.pool.get('account.tax')
49 for line in self.browse(cr, uid, ids, context=context):
50 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)
51 cur = line.order_id.pricelist_id.currency_id
52 res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
53 return res
54
55 def _qty_received(self, cr, uid, ids, prop, arg, context=None):
56 res = {}
57 for line in self.browse(cr, uid, ids, context=context):
58 qty = 0.0
59 for move in line.move_ids:
60 if move.state == 'done':
61 qty += move.product_qty
62 res[line.id] = qty
63 return res
64
65 def _qty_unreceived(self, cr, uid, ids, prop, arg, context=None):
66 res = {}
67 for line in self.browse(cr, uid, ids, context=context):
68 qty = 0.0
69 for move in line.move_ids:
70 if move.state not in ('done', 'cancel'):
71 qty += move.product_qty
72 res[line.id] = qty
73 return res
74
75 _columns = {
76 'modify_price': fields.boolean('Modify Price'),
77 'sequence': fields.integer('Sequence', help="Sequence for order in view and print report"),
78 'amount_subtotal': fields.function(_amount_line_with_tax, string='Subtotal(Inc. Tax)', type='float', digits_compute=dp.get_precision('Account')),
79 'qty_received': fields.function(_qty_received, string='Reception Qty', type='float', digits_compute=dp.get_precision('Product Unit of Measure')),
80 'qty_unreceived': fields.function(_qty_unreceived, string='Waiting Qty', type='float', digits_compute=dp.get_precision('Product Unit of Measure')),
81 'price_unit_original': fields.float('Original Unit Price', digits_compute=dp.get_precision('Product Price')),
82 #'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')),
83 }
84 _defaults = {
85 'sequence': 1,
86 'modify_price': False,
87 }
88
89
90 def onchange_price_unit(self, cr, uid, ids, partner_id, product_id, price_unit_original, price_unit, context=None):
91 #Not use at the moment! add a readonly attribute in view definition!
92 context = context or {}
93 res = {}
94
95 if not partner_id and not product_id:
96 return res
97 product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
98 partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
99
100 #if purchase_config_settings.po_price_modification_limit:
101 #if not product.po_price_modification_limit and not partner.po_price_modification_limit and price_unit_original != price_unit:
102 if not partner.po_price_modification_limit:
103
104 res['value'] = {'price_unit': price_unit_original}
105 res['warning'] = {'title' : _('PO Price'), 'message' : _('You can not modify the price of this product sold by this supplier !')}
106 #raise osv.except_osv(_('Error!'), _('You can not modify the price of this product sold by this supplier !'))
107 else:
108 res['value'] = {'price_unit_original':price_unit}
109 #ENDIF
110
111 return res
112
113purchase_order_line()
0114
=== added file 'purchase_po_price/purchase_view.xml'
--- purchase_po_price/purchase_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_po_price/purchase_view.xml 2013-08-19 07:16:14 +0000
@@ -0,0 +1,68 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="view_partner_form_joomla" model="ir.ui.view">
6 <field name="name">res.partner.form.FC</field>
7 <field name="model">res.partner</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="base.view_partner_form" />
10 <field name="arch" type="xml">
11 <xpath expr="//field[@name='customer']" position="after">
12
13 <field name="po_price_modification_limit" attrs="{'invisible':[('supplier','!=',True)]}"/>
14
15 <!-- <field name="supplier_product_limit" attrs="{'invisible':[('supplier','!=',True)]}"/> -->
16
17 </xpath>
18 </field>
19 </record>
20
21 <!-- <record id="product_normal_form_view_FC" model="ir.ui.view">
22 <field name="name">product.normal.form.FC</field>
23 <field name="model">product.product</field>
24 <field name="type">form</field>
25 <field name="inherit_id" ref="product.product_normal_form_view" />
26 <field name="arch" type="xml">
27 <xpath expr="//field[@name='uom_po_id']" position="after">
28 <field name="po_price_modification_limit"/>
29 </xpath>
30 </field>
31 </record> -->
32
33 <!-- Purchase Order -->
34 <record id="purchase_order_form_fc" model="ir.ui.view">
35 <field name="name">purchase.order.form_FC</field>
36 <field name="model">purchase.order</field>
37 <field name="type">form</field>
38 <field name="inherit_id" ref="purchase.purchase_order_form"/>
39 <field name="arch" type="xml">
40 <xpath expr="//field[@name='order_line']" position="replace">
41 <field name="order_line">
42 <tree string="Purchase Order Lines" editable="bottom">
43
44 <!-- field name="sequence"/>< by Andy-->
45 <field name="modify_price" invisible="1"/>
46 <!-- <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}"/> -->
47 <field name="name"/>
48 <field name="date_planned"/>
49 <field name="company_id" groups="base.group_multi_company" widget="selection"/>
50 <field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('parent_id','!=',False)]"/>
51 <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)"/>
52 <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)"/>
53 <!--field name="price_unit" attrs="{'readonly':[('modify_price','=',True)]}"/-->
54 <field name="price_unit_original" invisible="1"/>
55 <field name="price_unit" on_change="onchange_price_unit(parent.partner_id,product_id,price_unit_original,price_unit,context)"/>
56 <field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
57 <!-- <field name="price_unit_exclude_tax"/> -->
58 <field name="price_subtotal" invisible="1"/>
59 <field name="amount_subtotal"/><!-- by Andy-->
60
61 </tree>
62 </field>
63 </xpath>
64 </field>
65 </record>
66
67 </data>
68</openerp>
0\ No newline at end of file69\ No newline at end of file

Subscribers

People subscribed via source and target branches