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
=== added directory 'sale_sourced_by_line'
=== added file 'sale_sourced_by_line/__init__.py'
--- sale_sourced_by_line/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/__init__.py 2013-12-11 20:05:43 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Guewen Baconnier
5# Copyright 2013 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from . import model
023
=== added file 'sale_sourced_by_line/__openerp__.py'
--- sale_sourced_by_line/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/__openerp__.py 2013-12-11 20:05:43 +0000
@@ -0,0 +1,48 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Guewen Baconnier
5# Copyright 2013 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{'name': 'Sale Sourced by Line',
23 'version': '0.1',
24 'author': 'Camptocamp',
25 'category': 'Warehouse',
26 'license': 'AGPL-3',
27 'complexity': 'expert',
28 'images': [],
29 'website': "http://www.camptocamp.com",
30 'description': """
31Sale Sourced by Line
32====================
33
34Adds the possibility to source a line of sale order from a specific
35location instead of using the location of the warehouse of the selected
36shop
37""",
38 'depends': ['sale_stock',
39 ],
40 'demo': [],
41 'data': ['view/sale_view.xml',
42 ],
43 'test': ['test/sale_order_source.yml',
44 'test/sale_order_not_sourced.yml',
45 ],
46 'auto_install': False,
47 'installable': True,
48 }
049
=== added directory 'sale_sourced_by_line/i18n'
=== added directory 'sale_sourced_by_line/model'
=== added file 'sale_sourced_by_line/model/__init__.py'
--- sale_sourced_by_line/model/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/model/__init__.py 2013-12-11 20:05:43 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Guewen Baconnier
5# Copyright 2013 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from . import sale
023
=== added file 'sale_sourced_by_line/model/sale.py'
--- sale_sourced_by_line/model/sale.py 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/model/sale.py 2013-12-11 20:05:43 +0000
@@ -0,0 +1,54 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Guewen Baconnier
5# Copyright 2013 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import orm, fields
23
24
25class sale_order(orm.Model):
26 _inherit = 'sale.order'
27
28 def _prepare_order_line_move(self, cr, uid, order, line, picking_id,
29 date_planned, context=None):
30 values = super(sale_order, self)._prepare_order_line_move(
31 cr, uid, order, line, picking_id, date_planned, context=context)
32 if line.location_id:
33 values['location_id'] = line.location_id.id
34 return values
35
36 def _prepare_order_line_procurement(self, cr, uid, order, line, move_id,
37 date_planned, context=None):
38 values = super(sale_order, self)._prepare_order_line_procurement(
39 cr, uid, order, line, move_id, date_planned, context=context)
40 if line.location_id:
41 values['location_id'] = line.location_id.id
42 return values
43
44
45class sale_order_line(orm.Model):
46 _inherit = 'sale.order.line'
47
48 _columns = {
49 'location_id': fields.many2one(
50 'stock.location',
51 'Source Location',
52 help="If a source location is selected, "
53 "it will be used as source of the stock moves. "),
54 }
055
=== added directory 'sale_sourced_by_line/test'
=== added file 'sale_sourced_by_line/test/sale_order_not_sourced.yml'
--- sale_sourced_by_line/test/sale_order_not_sourced.yml 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/test/sale_order_not_sourced.yml 2013-12-11 20:05:43 +0000
@@ -0,0 +1,38 @@
1-
2 In order to check if the source location of a sale order line
3 still use the location of the shop if not specified on the
4 sale order line.
5-
6 !record {model: sale.order, id: sale_notsourced_01}:
7 partner_id: base.res_partner_2
8 note: Invoice after delivery
9 order_line:
10 - product_id: product.product_product_7
11 product_uom_qty: 8
12-
13 When I confirm the sale order
14-
15 !workflow {model: sale.order, action: order_confirm, ref: sale_notsourced_01}
16-
17 Then a delivery order should have been generated
18-
19 !python {model: sale.order}: |
20 sale_order = self.browse(cr, uid, ref("sale_notsourced_01"))
21 assert len(sale_order.picking_ids) == 1, (
22 "1 delivery order expected, got %d" % len(sale_order.picking_ids))
23-
24 And the source location of the stock move should be the one of
25 the sales order's shop
26-
27 !python {model: sale.order}: |
28 sale_order = self.browse(cr, uid, ref("sale_notsourced_01"))
29 picking = sale_order.picking_ids[0]
30 location_id = sale_order.shop_id.warehouse_id.lot_stock_id
31 for move in picking.move_lines:
32 assert move.location_id == location_id, (
33 "Wrong location_id, expected %s, got %s" %
34 (location_id, move.location_id))
35 for procurement in move.procurements:
36 assert procurement.location_id == location_id, (
37 "Wrong location_id in procurement.order, expected %s, got %s" %
38 (location_id, procurement.location_id))
039
=== added file 'sale_sourced_by_line/test/sale_order_source.yml'
--- sale_sourced_by_line/test/sale_order_source.yml 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/test/sale_order_source.yml 2013-12-11 20:05:43 +0000
@@ -0,0 +1,40 @@
1-
2 In order to check if the source location of a sale order line
3 becomes the source location of the delivery stock move.
4 I create a sale order.
5-
6 !record {model: sale.order, id: sale_source_01}:
7 partner_id: base.res_partner_2
8 note: Invoice after delivery
9 order_line:
10 - product_id: product.product_product_7
11 product_uom_qty: 8
12 location_id: stock.stock_location_shop1
13-
14 When I confirm the sale order
15-
16 !workflow {model: sale.order, action: order_confirm, ref: sale_source_01}
17-
18 Then a delivery order should have been generated
19-
20 !python {model: sale.order}: |
21 sale_order = self.browse(cr, uid, ref("sale_source_01"))
22 assert len(sale_order.picking_ids) == 1, (
23 "1 delivery order expected, got %d" % len(sale_order.picking_ids))
24-
25 And the source location of the stock move should be the one of
26 the sale order line
27-
28 !python {model: sale.order}: |
29 sale_order = self.browse(cr, uid, ref("sale_source_01"))
30 picking = sale_order.picking_ids[0]
31 for move in picking.move_lines:
32 expected_location_id = move.sale_line_id.location_id
33 assert move.location_id == expected_location_id, (
34 "Wrong location_id in stock.move, expected %s, got %s" %
35 (expected_location_id, move.location_id))
36 for procurement in move.procurements:
37 assert procurement.location_id == expected_location_id, (
38 "Wrong location_id in procurement.order, expected %s, got %s" %
39 (expected_location_id, procurement.location_id))
40
041
=== added directory 'sale_sourced_by_line/view'
=== added file 'sale_sourced_by_line/view/sale_view.xml'
--- sale_sourced_by_line/view/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_sourced_by_line/view/sale_view.xml 2013-12-11 20:05:43 +0000
@@ -0,0 +1,27 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="0">
4 <record id="view_order_form" model="ir.ui.view">
5 <field name="name">sale.order.form</field>
6 <field name="model">sale.order</field>
7 <field name="inherit_id" ref="sale.view_order_form"/>
8 <field name="arch" type="xml">
9 <xpath expr="//field[@name='order_line']/tree/field[@name='price_subtotal']"
10 position="after">
11 <field name="location_id"/>
12 </xpath>
13 </field>
14 </record>
15 <record id="view_order_form_form" model="ir.ui.view">
16 <field name="name">sale.order.form</field>
17 <field name="model">sale.order</field>
18 <field name="inherit_id" ref="sale.view_order_form"/>
19 <field name="arch" type="xml">
20 <xpath expr="//field[@name='order_line']/form/group/group/field[@name='product_id']"
21 position="after">
22 <field name="location_id" domain="[('usage', '!=', 'view')]"/>
23 </xpath>
24 </field>
25 </record>
26 </data>
27</openerp>

Subscribers

People subscribed via source and target branches