Merge lp:~akretion-team/carriers-deliveries/7-split-default-option-state-from-deliv-method-dbl into lp:~stock-logistic-core-editors/carriers-deliveries/7.0

Proposed by David BEAL (ak)
Status: Needs review
Proposed branch: lp:~akretion-team/carriers-deliveries/7-split-default-option-state-from-deliv-method-dbl
Merge into: lp:~stock-logistic-core-editors/carriers-deliveries/7.0
Diff against target: 178 lines (+76/-20)
5 files modified
base_delivery_carrier_label/__openerp__.py (+1/-1)
base_delivery_carrier_label/delivery.py (+19/-11)
base_delivery_carrier_label/delivery_view.xml (+11/-6)
base_delivery_carrier_label/migrations/7.0.1.2/pre-migration.py (+42/-0)
base_delivery_carrier_label/stock.py (+3/-2)
To merge this branch: bzr merge lp:~akretion-team/carriers-deliveries/7-split-default-option-state-from-deliv-method-dbl
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp Approve
Florian da Costa (community) Approve
Pedro Manuel Baeza code review Approve
Sébastien BEAU - http://www.akretion.com code review, no test Approve
Review via email: mp+224027@code.launchpad.net

Description of the change

Improve : split state field in two boolean fields with the same feature

To post a comment you must log in.
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Hi
You don't have to test "if available_option.mandatory is True" but you can only use "if available_option.mandatory" as it's a boolean the "is True" is useless.

review: Needs Fixing
53. By David BEAL (ak)

[FIX] boolean field evaluation

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

@sebastien,

fix done, thank you for review

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, David, thanks for the improvement.

You have to change module version number and provide a proper migration script for those that have previously the module installed.

Regards.

review: Approve (code review)
54. By David BEAL (ak)

[FIX] add migration script

55. By David BEAL (ak)

[FIX] module version

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Migrate script works for me.

I think it could merge

Only miss Yannick review

Revision history for this message
Florian da Costa (florian-dacosta) wrote :

It seems to work fine with chronopost module
Thanks

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

Just one inline comment

Otherwise LGTM

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

Ok failed my inline comment

l.102 <field name="code" readonly="1"/>

You can remove readonly here as you setted it on model

review: Approve
56. By David BEAL (ak)

[FIX] remove readonly in view for code field

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

l102 fixed, ready to merge

thanks to all

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

This project is now hosted on https://github.com/OCA/carriers-deliveries. Please move your proposal there if you still want to merge it once fixed. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

(sorry David should have merged it first at least this will make you some training to create PR on github ;) )

Unmerged revisions

56. By David BEAL (ak)

[FIX] remove readonly in view for code field

55. By David BEAL (ak)

[FIX] module version

54. By David BEAL (ak)

[FIX] add migration script

53. By David BEAL (ak)

[FIX] boolean field evaluation

52. By David BEAL (ak)

[FIX] split state field in two boolean field with the same feature

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'base_delivery_carrier_label/__openerp__.py'
--- base_delivery_carrier_label/__openerp__.py 2014-03-28 13:19:50 +0000
+++ base_delivery_carrier_label/__openerp__.py 2014-06-25 10:17:19 +0000
@@ -19,7 +19,7 @@
19#19#
20##############################################################################20##############################################################################
21{'name': 'Base module for carrier labels',21{'name': 'Base module for carrier labels',
22 'version': '1.1',22 'version': '1.2',
23 'author': 'Camptocamp,Akretion',23 'author': 'Camptocamp,Akretion',
24 'maintainer': 'Camptocamp',24 'maintainer': 'Camptocamp',
25 'category': 'version',25 'category': 'version',
2626
=== modified file 'base_delivery_carrier_label/delivery.py'
--- base_delivery_carrier_label/delivery.py 2014-03-31 08:09:39 +0000
+++ base_delivery_carrier_label/delivery.py 2014-06-25 10:17:19 +0000
@@ -32,12 +32,15 @@
32 'Partner Carrier'),32 'Partner Carrier'),
33 'name': fields.char(33 'name': fields.char(
34 'Name',34 'Name',
35 readonly=True,
35 size=64),36 size=64),
36 'code': fields.char(37 'code': fields.char(
37 'Code',38 'Code',
39 readonly=True,
38 size=64),40 size=64),
39 'description': fields.char(41 'description': fields.char(
40 'Description',42 'Description',
43 readonly=True,
41 help="Allow to define a more complete description "44 help="Allow to define a more complete description "
42 "than in the name field."),45 "than in the name field."),
43 }46 }
@@ -55,21 +58,26 @@
55 _inherits = {'delivery.carrier.template.option': 'tmpl_option_id'}58 _inherits = {'delivery.carrier.template.option': 'tmpl_option_id'}
5659
57 _columns = {60 _columns = {
58 'state': fields.selection(61 'mandatory': fields.boolean(
59 (('mandatory', 'Mandatory'),62 'Mandatory',
60 ('default_option', 'Optional by Default'),63 help="If checked, this option is necessarily applied to the picking"),
61 ('option', 'Optional'),64 'by_default': fields.boolean(
62 ),65 'Applied by Default',
63 string='Option Configuration',66 help="By check, user can choose to apply this option "
64 help="Ensure you add and define correctly all your options or those won't "67 "to each pickings\n using this delivery method"),
65 "be available for the packager\n"
66 "- Mandatory: This option will be copied on carrier and cannot be removed\n"
67 "- Optional by Default: This option will be copied but can be removed\n"
68 "- Optional: This option can be added later by the user on the Delivery Order."),
69 'tmpl_option_id': fields.many2one(68 'tmpl_option_id': fields.many2one(
70 'delivery.carrier.template.option',69 'delivery.carrier.template.option',
71 string='Option', required=True, ondelete="cascade"),70 string='Option', required=True, ondelete="cascade"),
72 'carrier_id': fields.many2one('delivery.carrier', 'Carrier'),71 'carrier_id': fields.many2one('delivery.carrier', 'Carrier'),
72 'readonly_flag': fields.boolean(
73 'Readonly Flag',
74 help="When True, help to prevent the user to modify some fields "
75 "option (if attribute is defined in the view)"),
76 }
77
78 _defaults = {
79 'readonly_flag': False,
80 'by_default': False,
73 }81 }
7482
7583
7684
=== modified file 'base_delivery_carrier_label/delivery_view.xml'
--- base_delivery_carrier_label/delivery_view.xml 2014-03-12 17:15:06 +0000
+++ base_delivery_carrier_label/delivery_view.xml 2014-06-25 10:17:19 +0000
@@ -35,10 +35,15 @@
35 <field name="model">delivery.carrier.option</field>35 <field name="model">delivery.carrier.option</field>
36 <field name="arch" type="xml">36 <field name="arch" type="xml">
37 <form string="delivery_carrier_option">37 <form string="delivery_carrier_option">
38 <field name="state"/>38 <group col="4">
39 <field name="tmpl_option_id"/>39 <field name="mandatory" attrs="{'readonly': [('readonly_flag','=',True)]}"/>
40 <newline/>40 <field name="by_default" attrs="{'invisible': [('mandatory', '=', True)]}"/>
41 <field name="description" colspan="4" readonly="True"/>41 <field name="readonly_flag" attrs="{'invisible': True}"/>
42 <field name="tmpl_option_id" colspan="4"
43 attrs="{'readonly': [('readonly_flag','=',True)]}"/>
44 <newline/>
45 <field name="description" colspan="4" readonly="True"/>
46 </group>
42 </form>47 </form>
43 </field>48 </field>
44 </record>49 </record>
@@ -49,9 +54,9 @@
49 <field name="type">tree</field>54 <field name="type">tree</field>
50 <field name="arch" type="xml">55 <field name="arch" type="xml">
51 <tree string="delivery_carrier_option">56 <tree string="delivery_carrier_option">
52 <field name="state" />57 <field name="mandatory" />
53 <field name="tmpl_option_id" />58 <field name="tmpl_option_id" />
54 <field name="code" readonly="1"/>59 <field name="code"/>
55 </tree>60 </tree>
56 </field>61 </field>
57 </record>62 </record>
5863
=== added directory 'base_delivery_carrier_label/migrations'
=== added directory 'base_delivery_carrier_label/migrations/7.0.1.2'
=== added file 'base_delivery_carrier_label/migrations/7.0.1.2/pre-migration.py'
--- base_delivery_carrier_label/migrations/7.0.1.2/pre-migration.py 1970-01-01 00:00:00 +0000
+++ base_delivery_carrier_label/migrations/7.0.1.2/pre-migration.py 2014-06-25 10:17:19 +0000
@@ -0,0 +1,42 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: David BEAL
5# Copyright 2014 Akretion
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
23def migrate(cr, version):
24 if not version:
25 return
26
27 queries = [
28 # build new fields
29 """ALTER TABLE delivery_carrier_option
30 ADD COLUMN mandatory BOOLEAN,
31 ADD COLUMN by_default BOOLEAN;""",
32 # move datas to new fields
33 """UPDATE delivery_carrier_option
34 SET mandatory = 't' WHERE state='mandatory';""",
35 """UPDATE delivery_carrier_option
36 SET by_default = 't' WHERE state='default_option';""",
37 # Delete old column
38 "ALTER TABLE delivery_carrier_option DROP COLUMN state;"
39 ]
40
41 for query in queries:
42 cr.execute(query)
043
=== modified file 'base_delivery_carrier_label/stock.py'
--- base_delivery_carrier_label/stock.py 2014-06-17 11:16:42 +0000
+++ base_delivery_carrier_label/stock.py 2014-06-25 10:17:19 +0000
@@ -163,7 +163,8 @@
163 available_option_ids = []163 available_option_ids = []
164 for available_option in carrier.available_option_ids:164 for available_option in carrier.available_option_ids:
165 available_option_ids.append(available_option.id)165 available_option_ids.append(available_option.id)
166 if available_option.state in ['default_option', 'mandatory']:166 if available_option.mandatory \
167 or available_option.by_default:
167 default_option_ids.append(available_option.id)168 default_option_ids.append(available_option.id)
168 res = {169 res = {
169 'value': {'carrier_type': carrier.type,170 'value': {'carrier_type': carrier.type,
@@ -182,7 +183,7 @@
182 return res183 return res
183 carrier = carrier_obj.browse(cr, uid, carrier_id, context=context)184 carrier = carrier_obj.browse(cr, uid, carrier_id, context=context)
184 for available_option in carrier.available_option_ids:185 for available_option in carrier.available_option_ids:
185 if (available_option.state == 'mandatory'186 if (available_option.mandatory
186 and not available_option.id in option_ids[0][2]):187 and not available_option.id in option_ids[0][2]):
187 res['warning'] = {188 res['warning'] = {
188 'title': _('User Error !'),189 'title': _('User Error !'),

Subscribers

People subscribed via source and target branches