openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #02995
lp:~camptocamp/carriers-deliveries/7.0-delivery_carrier_label_dispatch-options-yvr into lp:carriers-deliveries
Yannick Vaucher @ Camptocamp has proposed merging lp:~camptocamp/carriers-deliveries/7.0-delivery_carrier_label_dispatch-options-yvr into lp:carriers-deliveries with lp:~camptocamp/carriers-deliveries/7.0-add-delivery_carrier_label_dispatch-yvr as a prerequisite.
Requested reviews:
Leonardo Pistone @ camptocamp (lpistone): code review
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c): code review, no tests
For more details, see:
https://code.launchpad.net/~camptocamp/carriers-deliveries/7.0-delivery_carrier_label_dispatch-options-yvr/+merge/201007
Add carrier options on the dispatch in order to be able to massively change options on all related pickings
--
https://code.launchpad.net/~camptocamp/carriers-deliveries/7.0-delivery_carrier_label_dispatch-options-yvr/+merge/201007
Your team Stock and Logistic Core Editors is subscribed to branch lp:carriers-deliveries.
=== modified file 'delivery_carrier_label_dispatch/__init__.py'
--- delivery_carrier_label_dispatch/__init__.py 2014-01-17 15:52:44 +0000
+++ delivery_carrier_label_dispatch/__init__.py 2014-01-17 15:52:44 +0000
@@ -19,4 +19,5 @@
#
##############################################################################
from . import stock
+from . import picking_dispatch
from . import wizard
=== modified file 'delivery_carrier_label_dispatch/__openerp__.py'
--- delivery_carrier_label_dispatch/__openerp__.py 2014-01-17 15:52:44 +0000
+++ delivery_carrier_label_dispatch/__openerp__.py 2014-01-17 15:52:44 +0000
@@ -40,6 +40,7 @@
""",
'website': 'http://www.camptocamp.com/',
'data': [
+ 'picking_dispatch_view.xml',
'wizard/generate_labels_view.xml',
],
'tests': [],
=== modified file 'delivery_carrier_label_dispatch/i18n/delivery_carrier_label_dispatch.pot'
--- delivery_carrier_label_dispatch/i18n/delivery_carrier_label_dispatch.pot 2014-01-17 15:52:44 +0000
+++ delivery_carrier_label_dispatch/i18n/delivery_carrier_label_dispatch.pot 2014-01-17 15:52:44 +0000
@@ -6,34 +6,23 @@
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-12-06 13:11+0000\n"
-"PO-Revision-Date: 2013-12-06 13:11+0000\n"
-"Last-Translator: <>\n"
+"POT-Creation-Date: 2014-01-09 13:29+0000\n"
+"PO-Revision-Date: 2014-01-09 14:30+0100\n"
+"Last-Translator: Yannick Vaucher <yannick.vaucher@xxxxxxxxxxxxxx>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
+"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: delivery_carrier_label_dispatch
-#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:84
-#, python-format
-msgid "No picking dispatch selected"
-msgstr ""
-
-#. module: delivery_carrier_label_dispatch
-#: view:delivery.carrier.label.generate:0
-msgid "Generate Carriers Labels"
-msgstr ""
-
-#. module: delivery_carrier_label_dispatch
-#: view:delivery.carrier.label.generate:0
-msgid "Generate Labels"
-msgstr ""
-
-#. module: delivery_carrier_label_dispatch
-#: view:delivery.carrier.label.generate:0
-msgid "Labels"
+#: view:picking.dispatch:0
+msgid "Carrier Info"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.actions.act_window,name:delivery_carrier_label_dispatch.action_delivery_carrier_label_generate
+msgid "Generate Carrier Labels"
msgstr ""
#. module: delivery_carrier_label_dispatch
@@ -42,30 +31,99 @@
msgstr ""
#. module: delivery_carrier_label_dispatch
+#: code:addons/delivery_carrier_label_dispatch/picking_dispatch.py:100
+#, python-format
+msgid ""
+"You can not remove a mandatory option.\n"
+"Options are reset to default."
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.model,name:delivery_carrier_label_dispatch.model_picking_dispatch
+msgid "Dispatch Picking Order"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: view:picking.dispatch:0
+msgid "Delivery"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:58
+#, python-format
+msgid "No picking dispatch selected"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: field:delivery.carrier.label.generate,label_pdf_file:0
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_label_pdf_file
+msgid "Labels file"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: field:delivery.carrier.label.generate,dispatch_ids:0
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_dispatch_ids
+msgid "Picking Dispatch"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
#: model:ir.model,name:delivery_carrier_label_dispatch.model_delivery_carrier_label_generate
msgid "delivery.carrier.label.generate"
msgstr ""
#. module: delivery_carrier_label_dispatch
-#: model:ir.actions.act_window,name:delivery_carrier_label_dispatch.action_delivery_carrier_label_generate
-msgid "Generate Carrier Labels"
-msgstr ""
-
-#. module: delivery_carrier_label_dispatch
-#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:84
+#: view:picking.dispatch:0
+msgid "Set Options"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_picking_dispatch_carrier_id
+#: field:picking.dispatch,carrier_id:0
+msgid "Carrier"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:58
#, python-format
msgid "Error"
msgstr ""
#. module: delivery_carrier_label_dispatch
+#: view:picking.dispatch:0
+msgid "Warning, setting options will erase existing ones in pickings"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_picking_dispatch_option_ids
+#: view:picking.dispatch:0
+#: field:picking.dispatch,option_ids:0
+msgid "Options"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: view:delivery.carrier.label.generate:0
+msgid "Generate Labels"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: view:delivery.carrier.label.generate:0
+msgid "Labels"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
+#: view:delivery.carrier.label.generate:0
+msgid "Generate Carriers Labels"
+msgstr ""
+
+#. module: delivery_carrier_label_dispatch
#: view:delivery.carrier.label.generate:0
msgid "Close"
msgstr ""
#. module: delivery_carrier_label_dispatch
-#: field:delivery.carrier.label.generate,label_pdf_file:0
-#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_label_pdf_file
-msgid "Labels file"
+#: code:addons/delivery_carrier_label_dispatch/picking_dispatch.py:99
+#, python-format
+msgid "User Error !"
msgstr ""
#. module: delivery_carrier_label_dispatch
@@ -78,9 +136,3 @@
msgid "or"
msgstr ""
-#. module: delivery_carrier_label_dispatch
-#: field:delivery.carrier.label.generate,dispatch_ids:0
-#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_dispatch_ids
-msgid "Picking Dispatch"
-msgstr ""
-
=== modified file 'delivery_carrier_label_dispatch/i18n/fr.po'
--- delivery_carrier_label_dispatch/i18n/fr.po 2014-01-17 15:52:44 +0000
+++ delivery_carrier_label_dispatch/i18n/fr.po 2014-01-17 15:52:44 +0000
@@ -1,40 +1,30 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
-# * delivery_carrier_label_dispatch
+# * delivery_carrier_label_dispatch
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-12-06 13:11+0000\n"
-"PO-Revision-Date: 2013-12-06 14:46+0100\n"
+"POT-Creation-Date: 2014-01-09 13:29+0000\n"
+"PO-Revision-Date: 2014-01-09 14:51+0100\n"
"Last-Translator: Yannick Vaucher <yannick.vaucher@xxxxxxxxxxxxxx>\n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: delivery_carrier_label_dispatch
-#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:84
-#, python-format
-msgid "No picking dispatch selected"
-msgstr "Pas de bon de préparation sélectioné"
-
-#. module: delivery_carrier_label_dispatch
-#: view:delivery.carrier.label.generate:0
-msgid "Generate Carriers Labels"
-msgstr "Générer les étiquettes d'expédition"
-
-#. module: delivery_carrier_label_dispatch
-#: view:delivery.carrier.label.generate:0
-msgid "Generate Labels"
-msgstr "Générer les étiquettes"
-
-#. module: delivery_carrier_label_dispatch
-#: view:delivery.carrier.label.generate:0
-msgid "Labels"
-msgstr "Etiquettes"
+#: view:picking.dispatch:0
+msgid "Carrier Info"
+msgstr "Info transporteur"
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.actions.act_window,name:delivery_carrier_label_dispatch.action_delivery_carrier_label_generate
+msgid "Generate Carrier Labels"
+msgstr "Générer les étiquette d’expédition"
#. module: delivery_carrier_label_dispatch
#: model:ir.model,name:delivery_carrier_label_dispatch.model_stock_picking
@@ -42,31 +32,102 @@
msgstr "Liste de livraisons"
#. module: delivery_carrier_label_dispatch
+#: code:addons/delivery_carrier_label_dispatch/picking_dispatch.py:100
+#, python-format
+msgid ""
+"You can not remove a mandatory option.\n"
+"Options are reset to default."
+msgstr ""
+"Vous ne pouvez pas supprimer une option obligatoire.\n"
+"Les options serons réinitialisées."
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.model,name:delivery_carrier_label_dispatch.model_picking_dispatch
+msgid "Dispatch Picking Order"
+msgstr "Bon de préparation"
+
+#. module: delivery_carrier_label_dispatch
+#: view:picking.dispatch:0
+msgid "Delivery"
+msgstr "Livraison"
+
+#. module: delivery_carrier_label_dispatch
+#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:58
+#, python-format
+msgid "No picking dispatch selected"
+msgstr "Pas de bon de préparation sélectioné"
+
+#. module: delivery_carrier_label_dispatch
+#: field:delivery.carrier.label.generate,label_pdf_file:0
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_label_pdf_file
+msgid "Labels file"
+msgstr "Fichier d'étiquettes"
+
+#. module: delivery_carrier_label_dispatch
+#: field:delivery.carrier.label.generate,dispatch_ids:0
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_dispatch_ids
+msgid "Picking Dispatch"
+msgstr "Bon de préparation"
+
+#. module: delivery_carrier_label_dispatch
#: model:ir.model,name:delivery_carrier_label_dispatch.model_delivery_carrier_label_generate
msgid "delivery.carrier.label.generate"
msgstr ""
#. module: delivery_carrier_label_dispatch
-#: model:ir.actions.act_window,name:delivery_carrier_label_dispatch.action_delivery_carrier_label_generate
-msgid "Generate Carrier Labels"
-msgstr "Générer les étiquette d’expédition"
-
-#. module: delivery_carrier_label_dispatch
-#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:84
+#: view:picking.dispatch:0
+msgid "Set Options"
+msgstr "Appliquer les options"
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_picking_dispatch_carrier_id
+#: field:picking.dispatch,carrier_id:0
+msgid "Carrier"
+msgstr "Transporteur"
+
+#. module: delivery_carrier_label_dispatch
+#: code:addons/delivery_carrier_label_dispatch/wizard/generate_labels.py:58
#, python-format
msgid "Error"
msgstr "Erreur"
#. module: delivery_carrier_label_dispatch
+#: view:picking.dispatch:0
+msgid "Warning, setting options will erase existing ones in pickings"
+msgstr "Attention, définir les options supprimera les options existantes dans les livraisons du bon de préparation"
+
+#. module: delivery_carrier_label_dispatch
+#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_picking_dispatch_option_ids
+#: view:picking.dispatch:0
+#: field:picking.dispatch,option_ids:0
+msgid "Options"
+msgstr "Options"
+
+#. module: delivery_carrier_label_dispatch
+#: view:delivery.carrier.label.generate:0
+msgid "Generate Labels"
+msgstr "Générer les étiquettes"
+
+#. module: delivery_carrier_label_dispatch
+#: view:delivery.carrier.label.generate:0
+msgid "Labels"
+msgstr "Etiquettes"
+
+#. module: delivery_carrier_label_dispatch
+#: view:delivery.carrier.label.generate:0
+msgid "Generate Carriers Labels"
+msgstr "Générer les étiquettes d'expédition"
+
+#. module: delivery_carrier_label_dispatch
#: view:delivery.carrier.label.generate:0
msgid "Close"
msgstr "Fermer"
#. module: delivery_carrier_label_dispatch
-#: field:delivery.carrier.label.generate,label_pdf_file:0
-#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_label_pdf_file
-msgid "Labels file"
-msgstr "Fichier d'étiquettes"
+#: code:addons/delivery_carrier_label_dispatch/picking_dispatch.py:99
+#, python-format
+msgid "User Error !"
+msgstr "Erreur utilisateur !"
#. module: delivery_carrier_label_dispatch
#: model:ir.model,name:delivery_carrier_label_dispatch.model_stock_picking_out
@@ -78,9 +139,3 @@
msgid "or"
msgstr "ou"
-#. module: delivery_carrier_label_dispatch
-#: field:delivery.carrier.label.generate,dispatch_ids:0
-#: model:ir.model.fields,field_description:delivery_carrier_label_dispatch.field_delivery_carrier_label_generate_dispatch_ids
-msgid "Picking Dispatch"
-msgstr "Bon de préparation"
-
=== added file 'delivery_carrier_label_dispatch/picking_dispatch.py'
--- delivery_carrier_label_dispatch/picking_dispatch.py 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_dispatch/picking_dispatch.py 2014-01-17 15:52:44 +0000
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Yannick Vaucher
+# Copyright 2013 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from openerp.osv.orm import Model
+from openerp.osv import fields
+from openerp.tools.translate import _
+
+
+class PickingDispatch(Model):
+ """ Add carrier and carrier options on dispatch
+
+ to be able to massively set those options on related picking.
+
+ """
+ _inherit = "picking.dispatch"
+
+ _columns = {
+ 'carrier_id': fields.many2one(
+ 'delivery.carrier', 'Carrier',
+ states={'done': [('readonly', True)]}),
+ 'option_ids': fields.many2many(
+ 'delivery.carrier.option',
+ string='Options'),
+ }
+
+ def action_set_options(self, cr, uid, ids, context=None):
+ """ Apply options to picking of the dispatch
+
+ This will replace all carrier options in picking
+
+ """
+ picking_obj = self.pool.get('stock.picking')
+ for dispatch in self.browse(cr, uid, ids, context=context):
+ picking_ids = [p.id for p in dispatch.related_picking_ids]
+
+ option_ids = [o.id for o in dispatch.option_ids]
+ options_datas = {
+ 'carrier_id': dispatch.carrier_id.id,
+ 'option_ids': [(6, 0, option_ids)],
+ }
+ picking_obj.write(cr, uid, picking_ids,
+ options_datas, context=context)
+
+ def carrier_id_change(self, cr, uid, ids, carrier_id, context=None):
+ """ Inherit this method in your module """
+ carrier_obj = self.pool.get('delivery.carrier')
+ res = {}
+ if carrier_id:
+ carrier = carrier_obj.browse(cr, uid, carrier_id, context=context)
+ # This can look useless as the field carrier_code and
+ # carrier_type are related field. But it's needed to fill
+ # this field for using this fields in the view. Indeed the
+ # module that depend of delivery base can hide some field
+ # depending of the type or the code
+
+ default_option_ids = []
+ available_option_ids = []
+ for available_option in carrier.available_option_ids:
+ available_option_ids.append(available_option.id)
+ if available_option.state in ['default_option', 'mandatory']:
+ default_option_ids.append(available_option.id)
+ res = {
+ 'value': {'carrier_type': carrier.type,
+ 'carrier_code': carrier.code,
+ 'option_ids': default_option_ids,
+ },
+ 'domain': {'option_ids': [('id', 'in', available_option_ids)],
+ },
+ }
+ return res
+
+ def option_ids_change(self, cr, uid, ids, option_ids, carrier_id, context=None):
+ carrier_obj = self.pool.get('delivery.carrier')
+ res = {}
+ if not carrier_id:
+ return res
+ carrier = carrier_obj.browse(cr, uid, carrier_id, context=context)
+ for available_option in carrier.available_option_ids:
+ if (available_option.state == 'mandatory'
+ and not available_option.id in option_ids[0][2]):
+ res['warning'] = {
+ 'title': _('User Error !'),
+ 'message': _("You can not remove a mandatory option."
+ "\nOptions are reset to default.")
+ }
+ default_value = self.carrier_id_change(cr, uid, ids,
+ carrier_id,
+ context=context)
+ res.update(default_value)
+ return res
=== added file 'delivery_carrier_label_dispatch/picking_dispatch_view.xml'
--- delivery_carrier_label_dispatch/picking_dispatch_view.xml 1970-01-01 00:00:00 +0000
+++ delivery_carrier_label_dispatch/picking_dispatch_view.xml 2014-01-17 15:52:44 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record model="ir.ui.view" id="picking_dispatch_form">
+ <field name="name">picking.dispatch.form</field>
+ <field name="type">form</field>
+ <field name="model">picking.dispatch</field>
+ <field name="inherit_id" ref="picking_dispatch.picking_dispatch_form"/>
+ <field name="arch" type="xml">
+ <notebook position="inside">
+ <page name="carrier" string="Carrier Info">
+ <separator string="Delivery"/>
+ <group>
+ <field name="carrier_id" on_change="carrier_id_change(carrier_id, context)"/>
+ </group>
+ <separator string="Options"/>
+ <field name="option_ids" nolabel="1"
+ on_change="option_ids_change(option_ids, carrier_id, context)"/>
+ <label string="Warning, setting options will erase existing ones in pickings"/>
+ <button name="action_set_options" string="Set Options"
+ class="oe_highlight" type="object"/>
+ </page>
+ </notebook>
+ </field>
+ </record>
+
+ </data>
+</openerp>
References