Merge lp:~joao-gama/openerp-product-attributes/product_weight into lp:~product-core-editors/openerp-product-attributes/7.0

Proposed by Joao Alfredo Gama Batista
Status: Merged
Merged at revision: 197
Proposed branch: lp:~joao-gama/openerp-product-attributes/product_weight
Merge into: lp:~product-core-editors/openerp-product-attributes/7.0
Diff against target: 267 lines (+236/-0)
6 files modified
product_weight/__init__.py (+23/-0)
product_weight/__openerp__.py (+43/-0)
product_weight/product_view.xml (+21/-0)
product_weight/wizard/__init__.py (+23/-0)
product_weight/wizard/product_weight_update.py (+92/-0)
product_weight/wizard/product_weight_update_view.xml (+34/-0)
To merge this branch: bzr merge lp:~joao-gama/openerp-product-attributes/product_weight
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) Approve
Guewen Baconnier @ Camptocamp Pending
Review via email: mp+144982@code.launchpad.net

This proposal supersedes a proposal from 2013-01-17.

Description of the change

Add the module product_weight that calculates the product's net weight based on the product's components weight.

To post a comment you must log in.
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote : Posted in a previous version of this proposal

LGTM, not tested.

review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : Posted in a previous version of this proposal

Hello,

There is a real problem with the target branch lp:openerp-product-attributes/6.1

I had to rebuild it entirely from the history of the other branches.

You can read details here: https://code.launchpad.net/~product-core-editors/openerp-product-attributes/new6.1/+merge/143657

So, it means that this branch should be replaced. Can you propose again your merge when the branch will be replaced please ?

Sorry for the trouble.

Guewen

review: Abstain
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote : Posted in a previous version of this proposal

Target branch of this MP is 7.0.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : Posted in a previous version of this proposal

The 7.0 branch will have the same issue, the 'common ancestor' of the branches have to be the same than the extra-addons otherwise the merges won't work correctly.

Revision history for this message
Joao Alfredo Gama Batista (joao-gama) wrote : Posted in a previous version of this proposal

Hi Guewen,

No problem in proposing the merge again. Just let me know when the
branch will be replaced.

Thanks.

Joao

Le 2013-01-18 03:53, Guewen Baconnier @ Camptocamp a écrit :
> Review: Abstain
>
> Hello,
>
> There is a real problem with the target branch lp:openerp-product-attributes/6.1
>
> I had to rebuild it entirely from the history of the other branches.
>
> You can read details here: https://code.launchpad.net/~product-core-editors/openerp-product-attributes/new6.1/+merge/143657
>
> So, it means that this branch should be replaced. Can you propose again your merge when the branch will be replaced please ?
>
> Sorry for the trouble.
>
> Guewen
>

--
Joao Alfredo Gama Batista
Consultant en Logiciel Libre
Savoir-faire Linux inc.
<email address hidden>
+1 514 276-5468 poste 163

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : Posted in a previous version of this proposal

Hi Joao,

The branch is now rebuild properly.

Have a nice day
Guewen

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'product_weight'
=== added file 'product_weight/__init__.py'
--- product_weight/__init__.py 1970-01-01 00:00:00 +0000
+++ product_weight/__init__.py 2013-01-25 16:50:28 +0000
@@ -0,0 +1,23 @@
1# -*- coding: utf-8 -*-
2
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.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 wizard
024
=== added file 'product_weight/__openerp__.py'
--- product_weight/__openerp__.py 1970-01-01 00:00:00 +0000
+++ product_weight/__openerp__.py 2013-01-25 16:50:28 +0000
@@ -0,0 +1,43 @@
1# -*- coding: utf-8 -*-
2
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.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": "Product Weight Calculation",
25 "version": "0.1",
26 "author": "Savoir-faire Linux",
27 "website": "http://www.savoirfairelinux.com",
28 "license": "AGPL-3",
29 "category": "Warehouse",
30 "description": """
31 This module updates product net weight based on it's components weight
32 """,
33 "depends": [
34 "base",
35 "mrp",
36 ],
37 "demo": [],
38 "data": [
39 "wizard/product_weight_update_view.xml",
40 "product_view.xml",
41 ],
42 "installable": True,
43}
044
=== added file 'product_weight/product_view.xml'
--- product_weight/product_view.xml 1970-01-01 00:00:00 +0000
+++ product_weight/product_view.xml 2013-01-25 16:50:28 +0000
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="product_weight_form_view" model="ir.ui.view">
5 <field name="name">product.weight.form</field>
6 <field name="model">product.product</field>
7 <field name="inherit_id" ref="product.product_normal_form_view"/>
8 <field name="arch" type="xml">
9 <data>
10 <field name="weight_net" position="replace">
11 <label for="weight_net" />
12 <div>
13 <field name="weight_net" attrs="{'readonly': [('type','=','service')]}" class="oe_inline" />
14 <button name="%(action_view_product_weight_update)d" type="action" string="update" attrs="{'invisible':[('type','=','service')]}" class="oe_link" />
15 </div>
16 </field>
17 </data>
18 </field>
19 </record>
20 </data>
21</openerp>
022
=== added directory 'product_weight/wizard'
=== added file 'product_weight/wizard/__init__.py'
--- product_weight/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ product_weight/wizard/__init__.py 2013-01-25 16:50:28 +0000
@@ -0,0 +1,23 @@
1# -*- coding: utf-8 -*-
2
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.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 product_weight_update
024
=== added file 'product_weight/wizard/product_weight_update.py'
--- product_weight/wizard/product_weight_update.py 1970-01-01 00:00:00 +0000
+++ product_weight/wizard/product_weight_update.py 2013-01-25 16:50:28 +0000
@@ -0,0 +1,92 @@
1# -*- coding: utf-8 -*-
2
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.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 logging
24from openerp.osv import fields, osv
25from openerp.tools.translate import _
26
27_logger = logging.getLogger(__name__)
28
29
30class product_weight_update(osv.osv_memory):
31 _name = "product.weight.update"
32 _description = "Update Product Weight"
33 _columns = {
34 'product_id': fields.many2one('product.product', 'Product'),
35 'bom_id': fields.many2one('mrp.bom', 'BoM', domain="[('product_id', '=', product_id)]"),
36 }
37
38 def default_get(self, cr, uid, fields, context):
39 """ To get default values for the object.
40 @param self: The object pointer.
41 @param cr: A database cursor
42 @param uid: ID of the user currently logged in
43 @param fields: List of fields for which we want default values
44 @param context: A standard dictionary
45 @return: A dictionary which of fields with values.
46 """
47 product_id = context and context.get('active_id', False) or False
48 res = super(product_weight_update, self).default_get(cr, uid, fields, context=context)
49
50 bom_id = self.pool.get('mrp.bom').search(
51 cr, uid, [('product_id', '=', product_id)])[0]
52
53 if 'product_id' in fields:
54 res.update({'product_id': product_id})
55
56 res.update({'bom_id': bom_id})
57
58 return res
59
60 def update_weight(self, cr, uid, ids, context=None):
61 mrp_bom = self.pool.get("mrp.bom")
62 product_uom_categ = self.pool.get("product.uom.categ")
63 product_product = self.pool.get("product.product")
64
65 if context is None:
66 context = {}
67
68 rec_id = context and context.get('active_id', False)
69 assert rec_id, _('Active ID is not set in Context')
70
71 for i in self.browse(cr, uid, ids, context=context):
72 weight_net = 0.0
73 bom_ids = mrp_bom.search(cr, uid,
74 [('bom_id', '=', i.bom_id.id)])
75 for bom in mrp_bom.browse(cr, uid, bom_ids, context=context):
76 _logger.warning(_('Weight'))
77 if bom.product_uom.category_id.id == 2:
78 weight_net += bom.product_qty
79 else:
80 weight_net += (bom.product_qty * bom.product_id.weight_net)
81
82 _logger.warning("%s (%s): %0.2f" % (
83 bom.product_id.name,
84 bom.product_uom.category_id.name, weight_net))
85 weight_net = weight_net / mrp_bom.browse(
86 cr, uid, i.bom_id.id, context=context).product_qty
87 product_product.write(cr, uid, rec_id,
88 {'weight_net': weight_net},
89 context=context)
90 return {}
91
92product_weight_update()
093
=== added file 'product_weight/wizard/product_weight_update_view.xml'
--- product_weight/wizard/product_weight_update_view.xml 1970-01-01 00:00:00 +0000
+++ product_weight/wizard/product_weight_update_view.xml 2013-01-25 16:50:28 +0000
@@ -0,0 +1,34 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="view_product_weight_update" model="ir.ui.view">
5 <field name="name">Update Product Weight</field>
6 <field name="model">product.weight.update</field>
7 <field name="arch" type="xml">
8 <form string="Update Product Weight" version="7.0">
9 <group>
10 <field name="product_id" invisible="1" />
11 <field name="bom_id" />
12 </group>
13 <footer>
14 <button name="update_weight" string="_Apply" type="object" class="oe_highlight"/>
15 or
16 <button string="Cancel" class="oe_link" special="cancel" />
17 </footer>
18 </form>
19 </field>
20 </record>
21
22 <record id="action_view_product_weight_update" model="ir.actions.act_window">
23 <field name="name">Update Product Weight</field>
24 <field name="type">ir.actions.act_window</field>
25 <field name="res_model">product.weight.update</field>
26 <field name="view_type">form</field>
27 <field name="view_mode">form</field>
28 <field name="view_id" ref="view_product_weight_update"/>
29 <field name="target">new</field>
30 </record>
31
32 </data>
33</openerp>
34

Subscribers

People subscribed via source and target branches