Merge lp:~camptocamp/sale-wkfl/7.0-add-sale_sourced_and_stock_ownership into lp:~sale-core-editors/sale-wkfl/7.0

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Approved by: Yannick Vaucher @ Camptocamp
Approved revision: 36
Merged at revision: 29
Proposed branch: lp:~camptocamp/sale-wkfl/7.0-add-sale_sourced_and_stock_ownership
Merge into: lp:~sale-core-editors/sale-wkfl/7.0
Diff against target: 290 lines (+251/-0)
7 files modified
sale_sourced_by_line/__init__.py (+22/-0)
sale_sourced_by_line/__openerp__.py (+48/-0)
sale_sourced_by_line/model/__init__.py (+22/-0)
sale_sourced_by_line/model/sale.py (+54/-0)
sale_sourced_by_line/test/sale_order_not_sourced.yml (+38/-0)
sale_sourced_by_line/test/sale_order_source.yml (+40/-0)
sale_sourced_by_line/view/sale_view.xml (+27/-0)
To merge this branch: bzr merge lp:~camptocamp/sale-wkfl/7.0-add-sale_sourced_and_stock_ownership
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review, no tests Approve
Raphaël Valyi - http://www.akretion.com Approve
Romain Deheele - Camptocamp (community) code review, test Approve
Joël Grand-Guillaume @ camptocamp code review + test Needs Fixing
Review via email: mp+194527@code.launchpad.net

Description of the change

Add sale_sourced_by_line and stock_location_ownership addons

To post a comment you must log in.
33. By Nicolas Bessi - Camptocamp

[RM] dead code

34. By Nicolas Bessi - Camptocamp

[FIX] set installable to True

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Nicolas,

Thanks for extracting those modules ! I think it would be better to split this MP in two :

 * One fore sale_sourced_by_line and sale_ownership in this project

 * One for stock_location_ownership in this project I suggest: https://launchpad.net/stock-logistic-warehouse

I know dependencies are together here, but I'm in favor of giving the priority to modules purpose rather than publishing them by dependencies..

Regards,

Joël

review: Needs Fixing (code review + test)
35. By Nicolas Bessi - Camptocamp

[RM] sale_stock_ownership moved to https://launchpad.net/purchase-wkfl

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

sale_sourced_by_line's installable key has been set to False, by error I presume.
otherwise I test and it's ok.

Romain

review: Needs Fixing (code review and test)
36. By Guewen Baconnier @ Camptocamp

[FIX] set installable

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

Set to installable.

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

Romain, Joël, can you recheck please?

Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

Thanks,

Romain

review: Approve (code review, test)
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

LGTM, no tests

review: Approve
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM

Joël's Need Fixing was fixed by Nicolas I set this as Approved

review: Approve (code review, no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_sourced_by_line'
2=== added file 'sale_sourced_by_line/__init__.py'
3--- sale_sourced_by_line/__init__.py 1970-01-01 00:00:00 +0000
4+++ sale_sourced_by_line/__init__.py 2013-12-11 20:05:43 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Guewen Baconnier
10+# Copyright 2013 Camptocamp SA
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+from . import model
28
29=== added file 'sale_sourced_by_line/__openerp__.py'
30--- sale_sourced_by_line/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ sale_sourced_by_line/__openerp__.py 2013-12-11 20:05:43 +0000
32@@ -0,0 +1,48 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# Author: Guewen Baconnier
37+# Copyright 2013 Camptocamp SA
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU Affero General Public License as
41+# published by the Free Software Foundation, either version 3 of the
42+# License, or (at your option) any later version.
43+#
44+# This program is distributed in the hope that it will be useful,
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+# GNU Affero General Public License for more details.
48+#
49+# You should have received a copy of the GNU Affero General Public License
50+# along with this program. If not, see <http://www.gnu.org/licenses/>.
51+#
52+##############################################################################
53+
54+{'name': 'Sale Sourced by Line',
55+ 'version': '0.1',
56+ 'author': 'Camptocamp',
57+ 'category': 'Warehouse',
58+ 'license': 'AGPL-3',
59+ 'complexity': 'expert',
60+ 'images': [],
61+ 'website': "http://www.camptocamp.com",
62+ 'description': """
63+Sale Sourced by Line
64+====================
65+
66+Adds the possibility to source a line of sale order from a specific
67+location instead of using the location of the warehouse of the selected
68+shop
69+""",
70+ 'depends': ['sale_stock',
71+ ],
72+ 'demo': [],
73+ 'data': ['view/sale_view.xml',
74+ ],
75+ 'test': ['test/sale_order_source.yml',
76+ 'test/sale_order_not_sourced.yml',
77+ ],
78+ 'auto_install': False,
79+ 'installable': True,
80+ }
81
82=== added directory 'sale_sourced_by_line/i18n'
83=== added directory 'sale_sourced_by_line/model'
84=== added file 'sale_sourced_by_line/model/__init__.py'
85--- sale_sourced_by_line/model/__init__.py 1970-01-01 00:00:00 +0000
86+++ sale_sourced_by_line/model/__init__.py 2013-12-11 20:05:43 +0000
87@@ -0,0 +1,22 @@
88+# -*- coding: utf-8 -*-
89+##############################################################################
90+#
91+# Author: Guewen Baconnier
92+# Copyright 2013 Camptocamp SA
93+#
94+# This program is free software: you can redistribute it and/or modify
95+# it under the terms of the GNU Affero General Public License as
96+# published by the Free Software Foundation, either version 3 of the
97+# License, or (at your option) any later version.
98+#
99+# This program is distributed in the hope that it will be useful,
100+# but WITHOUT ANY WARRANTY; without even the implied warranty of
101+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102+# GNU Affero General Public License for more details.
103+#
104+# You should have received a copy of the GNU Affero General Public License
105+# along with this program. If not, see <http://www.gnu.org/licenses/>.
106+#
107+##############################################################################
108+
109+from . import sale
110
111=== added file 'sale_sourced_by_line/model/sale.py'
112--- sale_sourced_by_line/model/sale.py 1970-01-01 00:00:00 +0000
113+++ sale_sourced_by_line/model/sale.py 2013-12-11 20:05:43 +0000
114@@ -0,0 +1,54 @@
115+# -*- coding: utf-8 -*-
116+##############################################################################
117+#
118+# Author: Guewen Baconnier
119+# Copyright 2013 Camptocamp SA
120+#
121+# This program is free software: you can redistribute it and/or modify
122+# it under the terms of the GNU Affero General Public License as
123+# published by the Free Software Foundation, either version 3 of the
124+# License, or (at your option) any later version.
125+#
126+# This program is distributed in the hope that it will be useful,
127+# but WITHOUT ANY WARRANTY; without even the implied warranty of
128+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129+# GNU Affero General Public License for more details.
130+#
131+# You should have received a copy of the GNU Affero General Public License
132+# along with this program. If not, see <http://www.gnu.org/licenses/>.
133+#
134+##############################################################################
135+
136+from openerp.osv import orm, fields
137+
138+
139+class sale_order(orm.Model):
140+ _inherit = 'sale.order'
141+
142+ def _prepare_order_line_move(self, cr, uid, order, line, picking_id,
143+ date_planned, context=None):
144+ values = super(sale_order, self)._prepare_order_line_move(
145+ cr, uid, order, line, picking_id, date_planned, context=context)
146+ if line.location_id:
147+ values['location_id'] = line.location_id.id
148+ return values
149+
150+ def _prepare_order_line_procurement(self, cr, uid, order, line, move_id,
151+ date_planned, context=None):
152+ values = super(sale_order, self)._prepare_order_line_procurement(
153+ cr, uid, order, line, move_id, date_planned, context=context)
154+ if line.location_id:
155+ values['location_id'] = line.location_id.id
156+ return values
157+
158+
159+class sale_order_line(orm.Model):
160+ _inherit = 'sale.order.line'
161+
162+ _columns = {
163+ 'location_id': fields.many2one(
164+ 'stock.location',
165+ 'Source Location',
166+ help="If a source location is selected, "
167+ "it will be used as source of the stock moves. "),
168+ }
169
170=== added directory 'sale_sourced_by_line/test'
171=== added file 'sale_sourced_by_line/test/sale_order_not_sourced.yml'
172--- sale_sourced_by_line/test/sale_order_not_sourced.yml 1970-01-01 00:00:00 +0000
173+++ sale_sourced_by_line/test/sale_order_not_sourced.yml 2013-12-11 20:05:43 +0000
174@@ -0,0 +1,38 @@
175+-
176+ In order to check if the source location of a sale order line
177+ still use the location of the shop if not specified on the
178+ sale order line.
179+-
180+ !record {model: sale.order, id: sale_notsourced_01}:
181+ partner_id: base.res_partner_2
182+ note: Invoice after delivery
183+ order_line:
184+ - product_id: product.product_product_7
185+ product_uom_qty: 8
186+-
187+ When I confirm the sale order
188+-
189+ !workflow {model: sale.order, action: order_confirm, ref: sale_notsourced_01}
190+-
191+ Then a delivery order should have been generated
192+-
193+ !python {model: sale.order}: |
194+ sale_order = self.browse(cr, uid, ref("sale_notsourced_01"))
195+ assert len(sale_order.picking_ids) == 1, (
196+ "1 delivery order expected, got %d" % len(sale_order.picking_ids))
197+-
198+ And the source location of the stock move should be the one of
199+ the sales order's shop
200+-
201+ !python {model: sale.order}: |
202+ sale_order = self.browse(cr, uid, ref("sale_notsourced_01"))
203+ picking = sale_order.picking_ids[0]
204+ location_id = sale_order.shop_id.warehouse_id.lot_stock_id
205+ for move in picking.move_lines:
206+ assert move.location_id == location_id, (
207+ "Wrong location_id, expected %s, got %s" %
208+ (location_id, move.location_id))
209+ for procurement in move.procurements:
210+ assert procurement.location_id == location_id, (
211+ "Wrong location_id in procurement.order, expected %s, got %s" %
212+ (location_id, procurement.location_id))
213
214=== added file 'sale_sourced_by_line/test/sale_order_source.yml'
215--- sale_sourced_by_line/test/sale_order_source.yml 1970-01-01 00:00:00 +0000
216+++ sale_sourced_by_line/test/sale_order_source.yml 2013-12-11 20:05:43 +0000
217@@ -0,0 +1,40 @@
218+-
219+ In order to check if the source location of a sale order line
220+ becomes the source location of the delivery stock move.
221+ I create a sale order.
222+-
223+ !record {model: sale.order, id: sale_source_01}:
224+ partner_id: base.res_partner_2
225+ note: Invoice after delivery
226+ order_line:
227+ - product_id: product.product_product_7
228+ product_uom_qty: 8
229+ location_id: stock.stock_location_shop1
230+-
231+ When I confirm the sale order
232+-
233+ !workflow {model: sale.order, action: order_confirm, ref: sale_source_01}
234+-
235+ Then a delivery order should have been generated
236+-
237+ !python {model: sale.order}: |
238+ sale_order = self.browse(cr, uid, ref("sale_source_01"))
239+ assert len(sale_order.picking_ids) == 1, (
240+ "1 delivery order expected, got %d" % len(sale_order.picking_ids))
241+-
242+ And the source location of the stock move should be the one of
243+ the sale order line
244+-
245+ !python {model: sale.order}: |
246+ sale_order = self.browse(cr, uid, ref("sale_source_01"))
247+ picking = sale_order.picking_ids[0]
248+ for move in picking.move_lines:
249+ expected_location_id = move.sale_line_id.location_id
250+ assert move.location_id == expected_location_id, (
251+ "Wrong location_id in stock.move, expected %s, got %s" %
252+ (expected_location_id, move.location_id))
253+ for procurement in move.procurements:
254+ assert procurement.location_id == expected_location_id, (
255+ "Wrong location_id in procurement.order, expected %s, got %s" %
256+ (expected_location_id, procurement.location_id))
257+
258
259=== added directory 'sale_sourced_by_line/view'
260=== added file 'sale_sourced_by_line/view/sale_view.xml'
261--- sale_sourced_by_line/view/sale_view.xml 1970-01-01 00:00:00 +0000
262+++ sale_sourced_by_line/view/sale_view.xml 2013-12-11 20:05:43 +0000
263@@ -0,0 +1,27 @@
264+<?xml version="1.0" encoding="utf-8"?>
265+<openerp>
266+ <data noupdate="0">
267+ <record id="view_order_form" model="ir.ui.view">
268+ <field name="name">sale.order.form</field>
269+ <field name="model">sale.order</field>
270+ <field name="inherit_id" ref="sale.view_order_form"/>
271+ <field name="arch" type="xml">
272+ <xpath expr="//field[@name='order_line']/tree/field[@name='price_subtotal']"
273+ position="after">
274+ <field name="location_id"/>
275+ </xpath>
276+ </field>
277+ </record>
278+ <record id="view_order_form_form" model="ir.ui.view">
279+ <field name="name">sale.order.form</field>
280+ <field name="model">sale.order</field>
281+ <field name="inherit_id" ref="sale.view_order_form"/>
282+ <field name="arch" type="xml">
283+ <xpath expr="//field[@name='order_line']/form/group/group/field[@name='product_id']"
284+ position="after">
285+ <field name="location_id" domain="[('usage', '!=', 'view')]"/>
286+ </xpath>
287+ </field>
288+ </record>
289+ </data>
290+</openerp>

Subscribers

People subscribed via source and target branches