Merge lp:~camptocamp/carriers-deliveries/7.0-add-base_delivery_carrier_label-yvr into lp:~stock-logistic-core-editors/carriers-deliveries/7.0
- 7.0-add-base_delivery_carrier_label-yvr
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 8 |
Proposed branch: | lp:~camptocamp/carriers-deliveries/7.0-add-base_delivery_carrier_label-yvr |
Merge into: | lp:~stock-logistic-core-editors/carriers-deliveries/7.0 |
Diff against target: |
1112 lines (+1060/-0) 10 files modified
base_delivery_carrier_label/__init__.py (+22/-0) base_delivery_carrier_label/__openerp__.py (+62/-0) base_delivery_carrier_label/delivery.py (+84/-0) base_delivery_carrier_label/delivery_view.xml (+88/-0) base_delivery_carrier_label/i18n/base_delivery_carrier_label.pot (+212/-0) base_delivery_carrier_label/i18n/fr.po (+220/-0) base_delivery_carrier_label/reports.xml (+15/-0) base_delivery_carrier_label/security/ir.model.access.csv (+7/-0) base_delivery_carrier_label/stock.py (+295/-0) base_delivery_carrier_label/stock_view.xml (+55/-0) |
To merge this branch: | bzr merge lp:~camptocamp/carriers-deliveries/7.0-add-base_delivery_carrier_label-yvr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | code review, test | Approve | |
Joël Grand-Guillaume @ camptocamp | code review, no tests | Approve | |
Review via email: mp+196753@code.launchpad.net |
Commit message
Port of delivery_base and deliver_
Description of the change
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Thanks for the review.
I fixed carrier_
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Thanks for the change. You can totally remove the "carrier_
What about the access rights?
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
For access rights, salesmens need an access to select carrier on the sale order.
It is arguable if sale manager can edit or not a carrier.
However, I agree I have to add stock groups as well.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Thanks, looks good!
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Thanks !
I just removed the unsued tree view in stock_view.xml.
LGTM now.
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
I added tracking_id on shipping label in order to be able to create label per pack
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Thanks Yannick.
The docstring ":return: list of {tracking_id, file, file_type}" is confusing. What does it return? (it let me think of a set in the Python 2.7+ syntax: {1, 2}. Isn't it a tuple?
I think that tracking_id should not be mandatory, when we don't use the packs and only have a label per picking.
If you agree with that, 'tracking_id' returned by generate_
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Thanks for the review
Docstring improved, and code a bit adapted so tracking_id is not mandatory anymore in returned dict.
Plus renamed generate_
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Nice, thanks!
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
The security file was not loaded, fixed.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
I get this error:
Traceback (most recent call last):
File "/path/
result = ExportService.
File "/path/
res = fn(db, uid, *params)
File "/path/
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/path/
return f(self, dbname, *args, **kwargs)
File "/path/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/path/
return getattr(object, method)(cr, uid, *args, **kw)
File "/path/
File "/path/
'res_id': pick.id,
TypeError: 'type' object is unsubscriptable
When I use the button "Create Shipping Label" on a delivery order whose delivery method has no label configured.
The problem is in action_
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Thanks for the review I fixed that issue
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Neat, thanks for the new error message.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> Neat, thanks for the new error message.
And for the options on create() ;-)
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Fixed an issue of newly created delivery orders from sale order to set the options from the carrier_id
Plus improved the error message to be more generic if we don't want to install default labels.
Preview Diff
1 | === added directory 'base_delivery_carrier_label' |
2 | === added file 'base_delivery_carrier_label/__init__.py' |
3 | --- base_delivery_carrier_label/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ base_delivery_carrier_label/__init__.py 2014-01-15 13:14:41 +0000 |
5 | @@ -0,0 +1,22 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# Author: Yannick Vaucher |
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 | +from . import delivery |
27 | +from . import stock |
28 | |
29 | === added file 'base_delivery_carrier_label/__openerp__.py' |
30 | --- base_delivery_carrier_label/__openerp__.py 1970-01-01 00:00:00 +0000 |
31 | +++ base_delivery_carrier_label/__openerp__.py 2014-01-15 13:14:41 +0000 |
32 | @@ -0,0 +1,62 @@ |
33 | +# -*- coding: utf-8 -*- |
34 | +############################################################################## |
35 | +# |
36 | +# Author: Yannick Vaucher |
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 | +{'name': 'Base module for carrier labels', |
54 | + 'version': '1.0', |
55 | + 'author': 'Camptocamp,Akretion', |
56 | + 'maintainer': 'Camptocamp', |
57 | + 'category': 'version', |
58 | + 'complexity': 'normal', |
59 | + 'depends': ['stock', 'delivery'], |
60 | + 'description': """ |
61 | +Base module for carrier labels |
62 | +============================== |
63 | + |
64 | +This module adds a button on delivery orders to generate a label as an |
65 | +attachement. |
66 | + |
67 | +.. tip:: |
68 | + It doesn't implement a label. To add a default label, you can install |
69 | + the module `delivery_carrier_label_default_webkit` |
70 | + |
71 | +It can be used to print specific labels per carrier. |
72 | + |
73 | +.. note:: |
74 | + Inspired by Akretion module delivery_base and delivery_shipping_label |
75 | + |
76 | +Contributors |
77 | +------------ |
78 | + |
79 | +* David BEAL <david.beal@akretion.com> |
80 | +* Sébastien BEAU <sebastien.beau@akretion.com> |
81 | +* Yannick Vaucher <yannick.vaucher@camptocamp.com> |
82 | + |
83 | + """, |
84 | + 'website': 'http://www.camptocamp.com/', |
85 | + 'data': ['delivery_view.xml', |
86 | + 'stock_view.xml', |
87 | + 'security/ir.model.access.csv', |
88 | + ], |
89 | + 'tests': [], |
90 | + 'installable': True, |
91 | + 'auto_install': False, |
92 | + 'license': 'AGPL-3', |
93 | + 'application': True, |
94 | +} |
95 | |
96 | === added file 'base_delivery_carrier_label/delivery.py' |
97 | --- base_delivery_carrier_label/delivery.py 1970-01-01 00:00:00 +0000 |
98 | +++ base_delivery_carrier_label/delivery.py 2014-01-15 13:14:41 +0000 |
99 | @@ -0,0 +1,84 @@ |
100 | +# -*- coding: utf-8 -*- |
101 | +############################################################################## |
102 | +# |
103 | +# Author: Sébastien BEAU <sebastien.beau@akretion.com> |
104 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. |
105 | +# |
106 | +# This program is free software: you can redistribute it and/or modify |
107 | +# it under the terms of the GNU Affero General Public License as |
108 | +# published by the Free Software Foundation, either version 3 of the |
109 | +# License, or (at your option) any later version. |
110 | +# |
111 | +# This program is distributed in the hope that it will be useful, |
112 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
113 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
114 | +# GNU Affero General Public License for more details. |
115 | +# |
116 | +# You should have received a copy of the GNU Affero General Public License |
117 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
118 | +# |
119 | +############################################################################## |
120 | +from openerp.osv import orm, fields |
121 | + |
122 | + |
123 | +class DeliveryCarrierTemplateOption(orm.Model): |
124 | + """ Available options for a carrier (partner) """ |
125 | + _name = 'delivery.carrier.template.option' |
126 | + _description = 'Delivery carrier template option' |
127 | + |
128 | + _columns = { |
129 | + 'partner_id': fields.many2one('res.partner', 'Partner Carrier'), |
130 | + 'name': fields.char('Name', size=64), |
131 | + 'code': fields.char('Code', size=64), |
132 | + } |
133 | + |
134 | + |
135 | +class DeliveryCarrierOption(orm.Model): |
136 | + """ Option selected for a carrier method |
137 | + |
138 | + Those options define the list of available pre-added and available |
139 | + to be added on delivery orders |
140 | + |
141 | + """ |
142 | + _name = 'delivery.carrier.option' |
143 | + _description = 'Delivery carrier option' |
144 | + _inherits = {'delivery.carrier.template.option': 'tmpl_option_id'} |
145 | + |
146 | + _columns = { |
147 | + 'state': fields.selection( |
148 | + (('mandatory', 'Mandatory'), |
149 | + ('default_option', 'Optional by Default'), |
150 | + ('option', 'Optional'), |
151 | + ), |
152 | + string='Option Configuration', |
153 | + help="Ensure you add and define correctly all your options or those won't " |
154 | + "be available for the packager\n" |
155 | + "- Mandatory: This option will be copied on carrier and cannot be removed\n" |
156 | + "- Optional by Default: This option will be copied but can be removed\n" |
157 | + "- Optional: This option can be added later by the user on the Delivery Order."), |
158 | + 'tmpl_option_id': fields.many2one( |
159 | + 'delivery.carrier.template.option', |
160 | + string='Option', required=True, ondelete="cascade"), |
161 | + 'carrier_id': fields.many2one('delivery.carrier', 'Carrier'), |
162 | + } |
163 | + |
164 | + |
165 | +class DeliveryCarrier(orm.Model): |
166 | + _inherit = 'delivery.carrier' |
167 | + |
168 | + def _get_carrier_type_selection(self, cr, uid, context=None): |
169 | + """ To inherit to add carrier type """ |
170 | + return [] |
171 | + |
172 | + _columns = { |
173 | + 'type': fields.selection( |
174 | + _get_carrier_type_selection, 'Type', |
175 | + help="Carrier type (combines several delivery methods)"), |
176 | + 'code': fields.char( |
177 | + 'Code', size=10, |
178 | + help="Delivery Method Code (according to carrier)"), |
179 | + 'description': fields.text('Description'), |
180 | + 'available_option_ids': fields.one2many( |
181 | + 'delivery.carrier.option', |
182 | + 'carrier_id', 'Option'), |
183 | + } |
184 | |
185 | === added file 'base_delivery_carrier_label/delivery_view.xml' |
186 | --- base_delivery_carrier_label/delivery_view.xml 1970-01-01 00:00:00 +0000 |
187 | +++ base_delivery_carrier_label/delivery_view.xml 2014-01-15 13:14:41 +0000 |
188 | @@ -0,0 +1,88 @@ |
189 | +<?xml version="1.0" encoding="UTF-8"?> |
190 | +<openerp> |
191 | + <data> |
192 | + |
193 | + <!-- VIEW FOR THE OBJECT : delivery_carrier_template_option --> |
194 | + <record id="delivery_carrier_template_option_view_form" model="ir.ui.view"> |
195 | + <field name="name">delivery_base.delivery_carrier_option.view_form</field> |
196 | + <field name="model">delivery.carrier.template.option</field> |
197 | + <field name="arch" type="xml"> |
198 | + <form string="delivery_carrier_option"> |
199 | + <field name="partner_id" /> |
200 | + <field name="code"/> |
201 | + <field name="name"/> |
202 | + </form> |
203 | + </field> |
204 | + </record> |
205 | + |
206 | + <record id="delivery_carrier_template_option_view_tree" model="ir.ui.view"> |
207 | + <field name="name">delivery_base.delivery_carrier_template_option.view_tree</field> |
208 | + <field name="model">delivery.carrier.template.option</field> |
209 | + <field name="arch" type="xml"> |
210 | + <tree string="delivery_carrier_option"> |
211 | + <field name="partner_id" /> |
212 | + <field name="code"/> |
213 | + <field name="name"/> |
214 | + </tree> |
215 | + </field> |
216 | + </record> |
217 | + |
218 | + <!-- VIEW FOR THE OBJECT : delivery_carrier_option --> |
219 | + <record id="delivery_carrier_option_view_form" model="ir.ui.view"> |
220 | + <field name="name">delivery_base.delivery_carrier_option.view_form</field> |
221 | + <field name="model">delivery.carrier.option</field> |
222 | + <field name="arch" type="xml"> |
223 | + <form string="delivery_carrier_option"> |
224 | + <field name="state"/> |
225 | + <field name="tmpl_option_id"/> |
226 | + </form> |
227 | + </field> |
228 | + </record> |
229 | + |
230 | + <record id="delivery_carrier_option_view_tree" model="ir.ui.view"> |
231 | + <field name="name">delivery_base.delivery_carrier_option.view_tree</field> |
232 | + <field name="model">delivery.carrier.option</field> |
233 | + <field name="type">tree</field> |
234 | + <field name="arch" type="xml"> |
235 | + <tree string="delivery_carrier_option"> |
236 | + <field name="state" /> |
237 | + <field name="tmpl_option_id" /> |
238 | + <field name="code" readonly="1"/> |
239 | + </tree> |
240 | + </field> |
241 | + </record> |
242 | + |
243 | + <!-- INHERITED VIEW FOR THE OBJECT : delivery.carrier --> |
244 | + |
245 | + <record id="view_delivery_carrier_form" model="ir.ui.view"> |
246 | + <field name="name">delivery_base.delivery.carrier.view_form</field> |
247 | + <field name="model">delivery.carrier</field> |
248 | + <field name="inherit_id" ref="delivery.view_delivery_carrier_form"/> |
249 | + <field name="arch" type="xml"> |
250 | + <field name="pricelist_ids" position="after"> |
251 | + <separator string="Options" colspan="4"/> |
252 | + <field name="available_option_ids" nolabel="1" colspan="4"/> |
253 | + </field> |
254 | + <field name="active" position="after"> |
255 | + <field name="type"/> |
256 | + <field name="code"/> |
257 | + <separator name='description' colspan="4" string="Description"/> |
258 | + <field name="description" colspan="4" nolabel="1"/> |
259 | + </field> |
260 | + </field> |
261 | + </record> |
262 | + |
263 | + <record id="view_delivery_carrier_tree" model="ir.ui.view"> |
264 | + <field name="name">delivery_carrier_base.tree</field> |
265 | + <field name="model">delivery.carrier</field> |
266 | + <field name="inherit_id" ref="delivery.view_delivery_carrier_tree"/> |
267 | + <field name="arch" type="xml"> |
268 | + <field name="name" position="after"> |
269 | + <field name="type"/> |
270 | + <field name="code"/> |
271 | + </field> |
272 | + </field> |
273 | + </record> |
274 | + |
275 | + </data> |
276 | +</openerp> |
277 | |
278 | === added directory 'base_delivery_carrier_label/i18n' |
279 | === added file 'base_delivery_carrier_label/i18n/base_delivery_carrier_label.pot' |
280 | --- base_delivery_carrier_label/i18n/base_delivery_carrier_label.pot 1970-01-01 00:00:00 +0000 |
281 | +++ base_delivery_carrier_label/i18n/base_delivery_carrier_label.pot 2014-01-15 13:14:41 +0000 |
282 | @@ -0,0 +1,212 @@ |
283 | +# Translation of OpenERP Server. |
284 | +# This file contains the translation of the following modules: |
285 | +# * base_delivery_carrier_label |
286 | +# |
287 | +msgid "" |
288 | +msgstr "" |
289 | +"Project-Id-Version: OpenERP Server 7.0\n" |
290 | +"Report-Msgid-Bugs-To: \n" |
291 | +"POT-Creation-Date: 2013-12-06 13:11+0000\n" |
292 | +"PO-Revision-Date: 2013-12-06 13:11+0000\n" |
293 | +"Last-Translator: <>\n" |
294 | +"Language-Team: \n" |
295 | +"MIME-Version: 1.0\n" |
296 | +"Content-Type: text/plain; charset=UTF-8\n" |
297 | +"Content-Transfer-Encoding: \n" |
298 | +"Plural-Forms: \n" |
299 | + |
300 | +#. module: base_delivery_carrier_label |
301 | +#: view:stock.picking.out:0 |
302 | +msgid "Carrier Info" |
303 | +msgstr "" |
304 | + |
305 | +#. module: base_delivery_carrier_label |
306 | +#: model:ir.model,name:base_delivery_carrier_label.model_shipping_label |
307 | +msgid "Shipping Label" |
308 | +msgstr "" |
309 | + |
310 | +#. module: base_delivery_carrier_label |
311 | +#: model:ir.model,name:base_delivery_carrier_label.model_delivery_carrier_option |
312 | +msgid "Delivery carrier option" |
313 | +msgstr "" |
314 | + |
315 | +#. module: base_delivery_carrier_label |
316 | +#: model:ir.model,name:base_delivery_carrier_label.model_stock_picking |
317 | +msgid "Picking List" |
318 | +msgstr "" |
319 | + |
320 | +#. module: base_delivery_carrier_label |
321 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_carrier_type |
322 | +#: field:stock.picking.out,carrier_type:0 |
323 | +msgid "Carrier type" |
324 | +msgstr "" |
325 | + |
326 | +#. module: base_delivery_carrier_label |
327 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_shipping_label_attachment_id |
328 | +#: field:shipping.label,attachment_id:0 |
329 | +msgid "Automatically created field to link to parent ir.attachment" |
330 | +msgstr "" |
331 | + |
332 | +#. module: base_delivery_carrier_label |
333 | +#: field:delivery.carrier,type:0 |
334 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_type |
335 | +msgid "Type" |
336 | +msgstr "" |
337 | + |
338 | +#. module: base_delivery_carrier_label |
339 | +#: help:delivery.carrier,type:0 |
340 | +msgid "Carrier type (combines several delivery methods)" |
341 | +msgstr "" |
342 | + |
343 | +#. module: base_delivery_carrier_label |
344 | +#: code:addons/base_delivery_carrier_label/stock.py:143 |
345 | +#, python-format |
346 | +msgid "You can not remove a mandatory option.\n" |
347 | +"Options are reset to default." |
348 | +msgstr "" |
349 | + |
350 | +#. module: base_delivery_carrier_label |
351 | +#: view:delivery.carrier:0 |
352 | +#: field:delivery.carrier,description:0 |
353 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_description |
354 | +msgid "Description" |
355 | +msgstr "" |
356 | + |
357 | +#. module: base_delivery_carrier_label |
358 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_shipping_label_file_type |
359 | +#: field:shipping.label,file_type:0 |
360 | +msgid "File type" |
361 | +msgstr "" |
362 | + |
363 | +#. module: base_delivery_carrier_label |
364 | +#: view:stock.picking.out:0 |
365 | +msgid "Delivery" |
366 | +msgstr "" |
367 | + |
368 | +#. module: base_delivery_carrier_label |
369 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_carrier_code |
370 | +#: field:stock.picking.out,carrier_code:0 |
371 | +msgid "Delivery Method Code" |
372 | +msgstr "" |
373 | + |
374 | +#. module: base_delivery_carrier_label |
375 | +#: help:delivery.carrier,code:0 |
376 | +msgid "Delivery Method Code (according to carrier)" |
377 | +msgstr "" |
378 | + |
379 | +#. module: base_delivery_carrier_label |
380 | +#: selection:delivery.carrier.option,state:0 |
381 | +msgid "Optional" |
382 | +msgstr "" |
383 | + |
384 | +#. module: base_delivery_carrier_label |
385 | +#: field:delivery.carrier.template.option,name:0 |
386 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_template_option_name |
387 | +msgid "Name" |
388 | +msgstr "" |
389 | + |
390 | +#. module: base_delivery_carrier_label |
391 | +#: code:addons/base_delivery_carrier_label/stock.py:142 |
392 | +#, python-format |
393 | +msgid "User Error !" |
394 | +msgstr "" |
395 | + |
396 | +#. module: base_delivery_carrier_label |
397 | +#: view:stock.picking.out:0 |
398 | +msgid "Create Label" |
399 | +msgstr "" |
400 | + |
401 | +#. module: base_delivery_carrier_label |
402 | +#: field:delivery.carrier.option,carrier_id:0 |
403 | +#: model:ir.model,name:base_delivery_carrier_label.model_delivery_carrier |
404 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_option_carrier_id |
405 | +msgid "Carrier" |
406 | +msgstr "" |
407 | + |
408 | +#. module: base_delivery_carrier_label |
409 | +#: field:delivery.carrier.option,state:0 |
410 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_option_state |
411 | +msgid "Option Configuration" |
412 | +msgstr "" |
413 | + |
414 | +#. module: base_delivery_carrier_label |
415 | +#: view:delivery.carrier:0 |
416 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_option_ids |
417 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_option_ids_4475 |
418 | +#: field:stock.picking,option_ids:0 |
419 | +#: view:stock.picking.out:0 |
420 | +#: field:stock.picking.out,option_ids:0 |
421 | +msgid "Options" |
422 | +msgstr "" |
423 | + |
424 | +#. module: base_delivery_carrier_label |
425 | +#: field:delivery.carrier,available_option_ids:0 |
426 | +#: field:delivery.carrier.option,tmpl_option_id:0 |
427 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_available_option_ids |
428 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_option_tmpl_option_id |
429 | +msgid "Option" |
430 | +msgstr "" |
431 | + |
432 | +#. module: base_delivery_carrier_label |
433 | +#: help:stock.picking.out,carrier_code:0 |
434 | +msgid "Delivery Method Code (from carrier)" |
435 | +msgstr "" |
436 | + |
437 | +#. module: base_delivery_carrier_label |
438 | +#: field:delivery.carrier,code:0 |
439 | +#: field:delivery.carrier.template.option,code:0 |
440 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_code |
441 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_template_option_code |
442 | +msgid "Code" |
443 | +msgstr "" |
444 | + |
445 | +#. module: base_delivery_carrier_label |
446 | +#: selection:delivery.carrier.option,state:0 |
447 | +msgid "Mandatory" |
448 | +msgstr "" |
449 | + |
450 | +#. module: base_delivery_carrier_label |
451 | +#: help:stock.picking.out,carrier_type:0 |
452 | +msgid "Carrier type ('group')" |
453 | +msgstr "" |
454 | + |
455 | +#. module: base_delivery_carrier_label |
456 | +#: view:delivery.carrier.option:0 |
457 | +#: view:delivery.carrier.template.option:0 |
458 | +msgid "delivery_carrier_option" |
459 | +msgstr "" |
460 | + |
461 | +#. module: base_delivery_carrier_label |
462 | +#: model:ir.model,name:base_delivery_carrier_label.model_delivery_carrier_template_option |
463 | +msgid "Delivery carrier template option" |
464 | +msgstr "" |
465 | + |
466 | +#. module: base_delivery_carrier_label |
467 | +#: help:delivery.carrier.option,state:0 |
468 | +msgid "Ensure you add and define correctly all your options or those won't be available for the packager\n" |
469 | +"- Mandatory: This option will be copied on carrier and cannot be removed\n" |
470 | +"- Optional by Default: This option will be copied but can be removed\n" |
471 | +"- Optional: This option can be added later by the user on the Delivery Order." |
472 | +msgstr "" |
473 | + |
474 | +#. module: base_delivery_carrier_label |
475 | +#: field:delivery.carrier.template.option,partner_id:0 |
476 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_template_option_partner_id |
477 | +msgid "Partner Carrier" |
478 | +msgstr "" |
479 | + |
480 | +#. module: base_delivery_carrier_label |
481 | +#: model:ir.model,name:base_delivery_carrier_label.model_stock_picking_out |
482 | +msgid "Delivery Orders" |
483 | +msgstr "" |
484 | + |
485 | +#. module: base_delivery_carrier_label |
486 | +#: view:stock.picking.out:0 |
487 | +msgid "carrier_id_change(carrier_id, context)" |
488 | +msgstr "" |
489 | + |
490 | +#. module: base_delivery_carrier_label |
491 | +#: selection:delivery.carrier.option,state:0 |
492 | +msgid "Optional by Default" |
493 | +msgstr "" |
494 | + |
495 | |
496 | === added file 'base_delivery_carrier_label/i18n/fr.po' |
497 | --- base_delivery_carrier_label/i18n/fr.po 1970-01-01 00:00:00 +0000 |
498 | +++ base_delivery_carrier_label/i18n/fr.po 2014-01-15 13:14:41 +0000 |
499 | @@ -0,0 +1,220 @@ |
500 | +# Translation of OpenERP Server. |
501 | +# This file contains the translation of the following modules: |
502 | +# * base_delivery_carrier_label |
503 | +# |
504 | +msgid "" |
505 | +msgstr "" |
506 | +"Project-Id-Version: OpenERP Server 7.0\n" |
507 | +"Report-Msgid-Bugs-To: \n" |
508 | +"POT-Creation-Date: 2013-12-06 13:11+0000\n" |
509 | +"PO-Revision-Date: 2013-12-06 14:33+0100\n" |
510 | +"Last-Translator: Yannick Vaucher <yannick.vaucher@camptocamp.com>\n" |
511 | +"Language-Team: \n" |
512 | +"MIME-Version: 1.0\n" |
513 | +"Content-Type: text/plain; charset=UTF-8\n" |
514 | +"Content-Transfer-Encoding: 8bit\n" |
515 | +"Plural-Forms: \n" |
516 | + |
517 | +#. module: base_delivery_carrier_label |
518 | +#: view:stock.picking.out:0 |
519 | +msgid "Carrier Info" |
520 | +msgstr "Info transporteur" |
521 | + |
522 | +#. module: base_delivery_carrier_label |
523 | +#: model:ir.model,name:base_delivery_carrier_label.model_shipping_label |
524 | +msgid "Shipping Label" |
525 | +msgstr "Etiquette logistique" |
526 | + |
527 | +#. module: base_delivery_carrier_label |
528 | +#: model:ir.model,name:base_delivery_carrier_label.model_delivery_carrier_option |
529 | +msgid "Delivery carrier option" |
530 | +msgstr "" |
531 | + |
532 | +#. module: base_delivery_carrier_label |
533 | +#: model:ir.model,name:base_delivery_carrier_label.model_stock_picking |
534 | +msgid "Picking List" |
535 | +msgstr "Liste de livraison" |
536 | + |
537 | +#. module: base_delivery_carrier_label |
538 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_carrier_type |
539 | +#: field:stock.picking.out,carrier_type:0 |
540 | +msgid "Carrier type" |
541 | +msgstr "" |
542 | + |
543 | +#. module: base_delivery_carrier_label |
544 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_shipping_label_attachment_id |
545 | +#: field:shipping.label,attachment_id:0 |
546 | +msgid "Automatically created field to link to parent ir.attachment" |
547 | +msgstr "" |
548 | + |
549 | +#. module: base_delivery_carrier_label |
550 | +#: field:delivery.carrier,type:0 |
551 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_type |
552 | +msgid "Type" |
553 | +msgstr "Type" |
554 | + |
555 | +#. module: base_delivery_carrier_label |
556 | +#: help:delivery.carrier,type:0 |
557 | +msgid "Carrier type (combines several delivery methods)" |
558 | +msgstr "" |
559 | + |
560 | +#. module: base_delivery_carrier_label |
561 | +#: code:addons/base_delivery_carrier_label/stock.py:143 |
562 | +#, python-format |
563 | +msgid "" |
564 | +"You can not remove a mandatory option.\n" |
565 | +"Options are reset to default." |
566 | +msgstr "" |
567 | +"Vous ne pouvez pas supprimer une option obligatoire.\n" |
568 | +"Les options seront réinitialisées." |
569 | + |
570 | +#. module: base_delivery_carrier_label |
571 | +#: view:delivery.carrier:0 |
572 | +#: field:delivery.carrier,description:0 |
573 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_description |
574 | +msgid "Description" |
575 | +msgstr "Description" |
576 | + |
577 | +#. module: base_delivery_carrier_label |
578 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_shipping_label_file_type |
579 | +#: field:shipping.label,file_type:0 |
580 | +msgid "File type" |
581 | +msgstr "Type de fichier" |
582 | + |
583 | +#. module: base_delivery_carrier_label |
584 | +#: view:stock.picking.out:0 |
585 | +msgid "Delivery" |
586 | +msgstr "Livraison" |
587 | + |
588 | +#. module: base_delivery_carrier_label |
589 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_carrier_code |
590 | +#: field:stock.picking.out,carrier_code:0 |
591 | +msgid "Delivery Method Code" |
592 | +msgstr "Code de méthode de livraison" |
593 | + |
594 | +#. module: base_delivery_carrier_label |
595 | +#: help:delivery.carrier,code:0 |
596 | +msgid "Delivery Method Code (according to carrier)" |
597 | +msgstr "Code de méthode de livraison (en fonction du transporteur)" |
598 | + |
599 | +#. module: base_delivery_carrier_label |
600 | +#: selection:delivery.carrier.option,state:0 |
601 | +msgid "Optional" |
602 | +msgstr "Optionnel" |
603 | + |
604 | +#. module: base_delivery_carrier_label |
605 | +#: field:delivery.carrier.template.option,name:0 |
606 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_template_option_name |
607 | +msgid "Name" |
608 | +msgstr "Nom" |
609 | + |
610 | +#. module: base_delivery_carrier_label |
611 | +#: code:addons/base_delivery_carrier_label/stock.py:142 |
612 | +#, python-format |
613 | +msgid "User Error !" |
614 | +msgstr "Erreur utilisateur !" |
615 | + |
616 | +#. module: base_delivery_carrier_label |
617 | +#: view:stock.picking.out:0 |
618 | +msgid "Create Label" |
619 | +msgstr "Créer un label" |
620 | + |
621 | +#. module: base_delivery_carrier_label |
622 | +#: field:delivery.carrier.option,carrier_id:0 |
623 | +#: model:ir.model,name:base_delivery_carrier_label.model_delivery_carrier |
624 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_option_carrier_id |
625 | +msgid "Carrier" |
626 | +msgstr "Transporteur" |
627 | + |
628 | +#. module: base_delivery_carrier_label |
629 | +#: field:delivery.carrier.option,state:0 |
630 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_option_state |
631 | +msgid "Option Configuration" |
632 | +msgstr "Option de configuration" |
633 | + |
634 | +#. module: base_delivery_carrier_label |
635 | +#: view:delivery.carrier:0 |
636 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_option_ids |
637 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_stock_picking_option_ids_4475 |
638 | +#: field:stock.picking,option_ids:0 |
639 | +#: view:stock.picking.out:0 |
640 | +#: field:stock.picking.out,option_ids:0 |
641 | +msgid "Options" |
642 | +msgstr "Options" |
643 | + |
644 | +#. module: base_delivery_carrier_label |
645 | +#: field:delivery.carrier,available_option_ids:0 |
646 | +#: field:delivery.carrier.option,tmpl_option_id:0 |
647 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_available_option_ids |
648 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_option_tmpl_option_id |
649 | +msgid "Option" |
650 | +msgstr "Option" |
651 | + |
652 | +#. module: base_delivery_carrier_label |
653 | +#: help:stock.picking.out,carrier_code:0 |
654 | +msgid "Delivery Method Code (from carrier)" |
655 | +msgstr "Code de méthode de livraison (du transporteur)" |
656 | + |
657 | +#. module: base_delivery_carrier_label |
658 | +#: field:delivery.carrier,code:0 |
659 | +#: field:delivery.carrier.template.option,code:0 |
660 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_code |
661 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_template_option_code |
662 | +msgid "Code" |
663 | +msgstr "Code" |
664 | + |
665 | +#. module: base_delivery_carrier_label |
666 | +#: selection:delivery.carrier.option,state:0 |
667 | +msgid "Mandatory" |
668 | +msgstr "Obligatoire" |
669 | + |
670 | +#. module: base_delivery_carrier_label |
671 | +#: help:stock.picking.out,carrier_type:0 |
672 | +msgid "Carrier type ('group')" |
673 | +msgstr "" |
674 | + |
675 | +#. module: base_delivery_carrier_label |
676 | +#: view:delivery.carrier.option:0 |
677 | +#: view:delivery.carrier.template.option:0 |
678 | +msgid "delivery_carrier_option" |
679 | +msgstr "" |
680 | + |
681 | +#. module: base_delivery_carrier_label |
682 | +#: model:ir.model,name:base_delivery_carrier_label.model_delivery_carrier_template_option |
683 | +msgid "Delivery carrier template option" |
684 | +msgstr "Option de méthode de livraison" |
685 | + |
686 | +#. module: base_delivery_carrier_label |
687 | +#: help:delivery.carrier.option,state:0 |
688 | +msgid "" |
689 | +"Ensure you add and define correctly all your options or those won't be available for the packager\n" |
690 | +"- Mandatory: This option will be copied on carrier and cannot be removed\n" |
691 | +"- Optional by Default: This option will be copied but can be removed\n" |
692 | +"- Optional: This option can be added later by the user on the Delivery Order." |
693 | +msgstr "" |
694 | +"Assurez vous que vous avez défini correctement vos options ou celle ci ne sont pas disponible pour l'emballeur\n" |
695 | +"- Obligatoire: Cette option sera copiée sur la méthode de transport et ne peut pas être retirée\n" |
696 | +"- Optionnel par défaut: Cet option sera copiée mais peut être retirée\n" |
697 | +"- Optionnel: Cet option sera disponible pour être ajouté par l'utilisateur sur le Bon de livraison." |
698 | + |
699 | +#. module: base_delivery_carrier_label |
700 | +#: field:delivery.carrier.template.option,partner_id:0 |
701 | +#: model:ir.model.fields,field_description:base_delivery_carrier_label.field_delivery_carrier_template_option_partner_id |
702 | +msgid "Partner Carrier" |
703 | +msgstr "Partenaire transporteur" |
704 | + |
705 | +#. module: base_delivery_carrier_label |
706 | +#: model:ir.model,name:base_delivery_carrier_label.model_stock_picking_out |
707 | +msgid "Delivery Orders" |
708 | +msgstr "Bons de livraison" |
709 | + |
710 | +#. module: base_delivery_carrier_label |
711 | +#: view:stock.picking.out:0 |
712 | +msgid "carrier_id_change(carrier_id, context)" |
713 | +msgstr "" |
714 | + |
715 | +#. module: base_delivery_carrier_label |
716 | +#: selection:delivery.carrier.option,state:0 |
717 | +msgid "Optional by Default" |
718 | +msgstr "Optionnel par défaut" |
719 | + |
720 | |
721 | === added file 'base_delivery_carrier_label/reports.xml' |
722 | --- base_delivery_carrier_label/reports.xml 1970-01-01 00:00:00 +0000 |
723 | +++ base_delivery_carrier_label/reports.xml 2014-01-15 13:14:41 +0000 |
724 | @@ -0,0 +1,15 @@ |
725 | +<?xml version="1.0" encoding="utf-8"?> |
726 | +<openerp> |
727 | + <data> |
728 | + <report |
729 | + auto="False" |
730 | + id="delivery.shipping_label" |
731 | + model="stock.picking" |
732 | + name="delivery.shipping.label" |
733 | + file="base_delivery_carrier_label/report/template/shipping_label.mako" |
734 | + string="Shipping Label" |
735 | + attachment_use="1" |
736 | + multi="False" |
737 | + report_type="webkit"/> |
738 | + </data> |
739 | +</openerp> |
740 | |
741 | === added directory 'base_delivery_carrier_label/security' |
742 | === added file 'base_delivery_carrier_label/security/ir.model.access.csv' |
743 | --- base_delivery_carrier_label/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
744 | +++ base_delivery_carrier_label/security/ir.model.access.csv 2014-01-15 13:14:41 +0000 |
745 | @@ -0,0 +1,7 @@ |
746 | +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
747 | +access_delivery_carrier_option_salesman,delivery.carrier.option.salesman,model_delivery_carrier_option,base.group_sale_salesman,1,0,0,0 |
748 | +access_delivery_carrier_option_sale_manager,delivery.carrier.option.sale.manager,model_delivery_carrier_option,base.group_sale_manager,1,1,1,1 |
749 | +access_delivery_carrier_template_option_salesman,delivery.carrier.relation.option.salesman,model_delivery_carrier_template_option,base.group_sale_salesman,1,0,0,0 |
750 | +access_delivery_carrier_template_option_sales_manager,delivery.carrier.relation.option.sale.manager,model_delivery_carrier_template_option,base.group_sale_manager,1,1,1,1 |
751 | +access_shipping_label_user,shipping.label user,model_shipping_label,stock.group_stock_user,1,1,1,0 |
752 | +access_shipping_label_manager,shipping.label manager,model_shipping_label,stock.group_stock_manager,1,1,1,1 |
753 | |
754 | === added file 'base_delivery_carrier_label/stock.py' |
755 | --- base_delivery_carrier_label/stock.py 1970-01-01 00:00:00 +0000 |
756 | +++ base_delivery_carrier_label/stock.py 2014-01-15 13:14:41 +0000 |
757 | @@ -0,0 +1,295 @@ |
758 | +# -*- coding: utf-8 -*- |
759 | +############################################################################## |
760 | +# |
761 | +# Authors: David BEAL <david.beal@akretion.com> |
762 | +# Sébastien BEAU <sebastien.beau@akretion.com> |
763 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. |
764 | +# Author: Yannick Vaucher <yannick.vaucher@camptocamp.com> |
765 | +# Copyright 2013 Camptocamp SA |
766 | +# |
767 | +# This program is free software: you can redistribute it and/or modify |
768 | +# it under the terms of the GNU Affero General Public License as |
769 | +# published by the Free Software Foundation, either version 3 of the |
770 | +# License, or (at your option) any later version. |
771 | +# |
772 | +# This program is distributed in the hope that it will be useful, |
773 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
774 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
775 | +# GNU Affero General Public License for more details. |
776 | +# |
777 | +# You should have received a copy of the GNU Affero General Public License |
778 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
779 | +# |
780 | +############################################################################## |
781 | +from openerp.osv import orm, fields |
782 | +from openerp.tools.translate import _ |
783 | + |
784 | + |
785 | +class stock_picking(orm.Model): |
786 | + _inherit = 'stock.picking' |
787 | + |
788 | + def _get_carrier_type_selection(self, cr, uid, context=None): |
789 | + carrier_obj = self.pool.get('delivery.carrier') |
790 | + return carrier_obj._get_carrier_type_selection(cr, uid, context=context) |
791 | + |
792 | + _columns = { |
793 | + 'carrier_id': fields.many2one( |
794 | + 'delivery.carrier', 'Carrier', |
795 | + states={'done': [('readonly', True)]}), |
796 | + 'carrier_type': fields.related( |
797 | + 'carrier_id', 'type', |
798 | + string='Carrier type', |
799 | + readonly=True, |
800 | + type='selection', |
801 | + selection=_get_carrier_type_selection, |
802 | + help="Carrier type ('group')"), |
803 | + 'carrier_code': fields.related( |
804 | + 'carrier_id', 'code', |
805 | + string='Delivery Method Code', |
806 | + readonly=True, |
807 | + type='char', |
808 | + help="Delivery Method Code (from carrier)"), |
809 | + 'option_ids': fields.many2many('delivery.carrier.option', |
810 | + string='Options'), |
811 | + } |
812 | + |
813 | + def generate_default_label(self, cr, uid, ids, context=None): |
814 | + """ Abstract method |
815 | + |
816 | + :return: (file_binary, file_type) |
817 | + |
818 | + """ |
819 | + raise orm.except_orm( |
820 | + 'Error', |
821 | + 'No label is configured for selected delivery method.') |
822 | + |
823 | + def generate_shipping_labels(self, cr, uid, ids, context=None): |
824 | + """Generate a shipping label by default |
825 | + |
826 | + This method can be inherited to create specific shipping labels |
827 | + a list of label must be return as we can have multiple |
828 | + stock.tracking for a single picking representing packs |
829 | + |
830 | + :return: list of dict containing |
831 | + name: name to give to the attachement |
832 | + file: file as string |
833 | + file_type: string of file type like 'PDF' |
834 | + (optional) |
835 | + tracking_id: tracking_id if picking lines have tracking_id and |
836 | + if label generator creates shipping label per |
837 | + pack |
838 | + |
839 | + """ |
840 | + return [self.generate_default_label(cr, uid, ids, context=None)] |
841 | + |
842 | + def action_generate_carrier_label(self, cr, uid, ids, context=None): |
843 | + shipping_label_obj = self.pool.get('shipping.label') |
844 | + |
845 | + pickings = self.browse(cr, uid, ids, context=context) |
846 | + |
847 | + for pick in pickings: |
848 | + shipping_labels = pick.generate_shipping_labels() |
849 | + for label in shipping_labels: |
850 | + # map types with models |
851 | + types = {'in': 'stock.picking.in', |
852 | + 'out': 'stock.picking.out', |
853 | + 'internal': 'stock.picking', |
854 | + } |
855 | + res_model = types[pick.type] |
856 | + data = { |
857 | + 'name': label['name'], |
858 | + 'res_id': pick.id, |
859 | + 'res_model': res_model, |
860 | + 'datas': label['file'].encode('base64'), |
861 | + 'file_type': label['file_type'], |
862 | + } |
863 | + if label.get('tracking_id'): |
864 | + data['tracking_id'] = label['tracking_id'] |
865 | + context_attachment = context.copy() |
866 | + # remove default_type setted for stock_picking |
867 | + # as it would try to define default value of attachement |
868 | + if 'default_type' in context_attachment: |
869 | + del context_attachment['default_type'] |
870 | + shipping_label_obj.create(cr, uid, data, context=context_attachment) |
871 | + return True |
872 | + |
873 | + def carrier_id_change(self, cr, uid, ids, carrier_id, context=None): |
874 | + """ Inherit this method in your module """ |
875 | + carrier_obj = self.pool.get('delivery.carrier') |
876 | + res = {} |
877 | + if carrier_id: |
878 | + carrier = carrier_obj.browse(cr, uid, carrier_id, context=context) |
879 | + # This can look useless as the field carrier_code and |
880 | + # carrier_type are related field. But it's needed to fill |
881 | + # this field for using this fields in the view. Indeed the |
882 | + # module that depend of delivery base can hide some field |
883 | + # depending of the type or the code |
884 | + |
885 | + default_option_ids = [] |
886 | + available_option_ids = [] |
887 | + for available_option in carrier.available_option_ids: |
888 | + available_option_ids.append(available_option.id) |
889 | + if available_option.state in ['default_option', 'mandatory']: |
890 | + default_option_ids.append(available_option.id) |
891 | + res = { |
892 | + 'value': {'carrier_type': carrier.type, |
893 | + 'carrier_code': carrier.code, |
894 | + 'option_ids': default_option_ids, |
895 | + }, |
896 | + 'domain': {'option_ids': [('id', 'in', available_option_ids)], |
897 | + }, |
898 | + } |
899 | + return res |
900 | + |
901 | + def option_ids_change(self, cr, uid, ids, option_ids, carrier_id, context=None): |
902 | + carrier_obj = self.pool.get('delivery.carrier') |
903 | + res = {} |
904 | + if not carrier_id: |
905 | + return res |
906 | + carrier = carrier_obj.browse(cr, uid, carrier_id, context=context) |
907 | + for available_option in carrier.available_option_ids: |
908 | + if (available_option.state == 'mandatory' |
909 | + and not available_option.id in option_ids[0][2]): |
910 | + res['warning'] = { |
911 | + 'title': _('User Error !'), |
912 | + 'message': _("You can not remove a mandatory option." |
913 | + "\nOptions are reset to default.") |
914 | + } |
915 | + default_value = self.carrier_id_change(cr, uid, ids, |
916 | + carrier_id, |
917 | + context=context) |
918 | + res.update(default_value) |
919 | + return res |
920 | + |
921 | + def create(self, cr, uid, values, context=None): |
922 | + """ Trigger carrier_id_change on create |
923 | + |
924 | + To ensure options are setted on the basis of carrier_id copied from |
925 | + Sale order or defined by default. |
926 | + |
927 | + """ |
928 | + carrier_id = values.get('carrier_id') |
929 | + if carrier_id: |
930 | + picking_obj = self.pool.get('stock.picking') |
931 | + res = picking_obj.carrier_id_change(cr, uid, [], carrier_id, |
932 | + context=context) |
933 | + option_ids = res.get('value', {}).get('option_ids') |
934 | + if option_ids: |
935 | + values.update(option_ids=[(6, 0, option_ids)]) |
936 | + picking_id = super(stock_picking, self |
937 | + ).create(cr, uid, values, context=context) |
938 | + return picking_id |
939 | + |
940 | + |
941 | +class stock_picking_in(orm.Model): |
942 | + """ Add what isn't inherited from stock.picking """ |
943 | + _inherit = 'stock.picking.in' |
944 | + |
945 | + def _get_carrier_type_selection(self, cr, uid, context=None): |
946 | + carrier_obj = self.pool.get('delivery.carrier') |
947 | + return carrier_obj._get_carrier_type_selection(cr, uid, context=context) |
948 | + |
949 | + _columns = { |
950 | + 'carrier_id': fields.many2one( |
951 | + 'delivery.carrier', 'Carrier', |
952 | + states={'done': [('readonly', True)]}), |
953 | + 'carrier_type': fields.related( |
954 | + 'carrier_id', 'type', |
955 | + string='Carrier type', |
956 | + readonly=True, |
957 | + type='selection', |
958 | + selection=_get_carrier_type_selection, |
959 | + help="Carrier type ('group')"), |
960 | + 'carrier_code': fields.related( |
961 | + 'carrier_id', 'code', |
962 | + string='Delivery Method Code', |
963 | + readonly=True, |
964 | + type='char', |
965 | + help="Delivery Method Code (from carrier)"), |
966 | + 'option_ids': fields.many2many('delivery.carrier.option', |
967 | + string='Options'), |
968 | + } |
969 | + |
970 | + def action_generate_carrier_label(self, cr, uid, ids, context=None): |
971 | + picking_obj = self.pool.get('stock.picking') |
972 | + return picking_obj.action_generate_carrier_label(cr, uid, ids, |
973 | + context=context) |
974 | + |
975 | + def carrier_id_change(self, cr, uid, ids, carrier_id, context=None): |
976 | + """ Call stock.picking carrier_id_change """ |
977 | + picking_obj = self.pool.get('stock.picking') |
978 | + return picking_obj.carrier_id_change(cr, uid, ids, |
979 | + carrier_id, context=context) |
980 | + |
981 | + def option_ids_change(self, cr, uid, ids, |
982 | + option_ids, carrier_id, context=None): |
983 | + """ Call stock.picking option_ids_change """ |
984 | + picking_obj = self.pool.get('stock.picking') |
985 | + return picking_obj.option_ids_change(cr, uid, ids, |
986 | + option_ids, carrier_id, |
987 | + context=context) |
988 | + |
989 | + |
990 | +class stock_picking_out(orm.Model): |
991 | + """ Add what isn't inherited from stock.picking """ |
992 | + _inherit = 'stock.picking.out' |
993 | + |
994 | + def _get_carrier_type_selection(self, cr, uid, context=None): |
995 | + carrier_obj = self.pool.get('delivery.carrier') |
996 | + return carrier_obj._get_carrier_type_selection(cr, uid, context=context) |
997 | + |
998 | + _columns = { |
999 | + 'carrier_id': fields.many2one( |
1000 | + 'delivery.carrier', 'Carrier', |
1001 | + states={'done': [('readonly', True)]}), |
1002 | + 'carrier_type': fields.related( |
1003 | + 'carrier_id', 'type', |
1004 | + string='Carrier type', |
1005 | + readonly=True, |
1006 | + type='selection', |
1007 | + selection=_get_carrier_type_selection, |
1008 | + help="Carrier type ('group')"), |
1009 | + 'carrier_code': fields.related( |
1010 | + 'carrier_id', 'code', |
1011 | + string='Delivery Method Code', |
1012 | + readonly=True, |
1013 | + type='char', |
1014 | + help="Delivery Method Code (from carrier)"), |
1015 | + 'option_ids': fields.many2many('delivery.carrier.option', |
1016 | + string='Options'), |
1017 | + } |
1018 | + |
1019 | + def action_generate_carrier_label(self, cr, uid, ids, context=None): |
1020 | + picking_obj = self.pool.get('stock.picking') |
1021 | + return picking_obj.action_generate_carrier_label(cr, uid, ids, |
1022 | + context=context) |
1023 | + |
1024 | + def carrier_id_change(self, cr, uid, ids, carrier_id, context=None): |
1025 | + """ Inherit this method in your module """ |
1026 | + picking_obj = self.pool.get('stock.picking') |
1027 | + return picking_obj.carrier_id_change(cr, uid, ids, carrier_id, context=context) |
1028 | + |
1029 | + def option_ids_change(self, cr, uid, ids, option_ids, carrier_id, context=None): |
1030 | + picking_obj = self.pool.get('stock.picking') |
1031 | + return picking_obj.option_ids_change(cr, uid, ids, |
1032 | + option_ids, carrier_id, |
1033 | + context=context) |
1034 | + |
1035 | + |
1036 | +class ShippingLabel(orm.Model): |
1037 | + """ Child class of ir attachment to identify which are labels """ |
1038 | + _inherits = {'ir.attachment': 'attachment_id'} |
1039 | + _name = 'shipping.label' |
1040 | + _description = "Shipping Label" |
1041 | + |
1042 | + def _get_file_type_selection(self, cr, uid, context=None): |
1043 | + return [('pdf', 'PDF')] |
1044 | + |
1045 | + _columns = { |
1046 | + 'file_type': fields.selection(_get_file_type_selection, 'File type'), |
1047 | + 'tracking_id': fields.many2one('stock.tracking', 'Pack'), |
1048 | + } |
1049 | + |
1050 | + _defaults = { |
1051 | + 'file_type': 'pdf' |
1052 | + } |
1053 | |
1054 | === added file 'base_delivery_carrier_label/stock_view.xml' |
1055 | --- base_delivery_carrier_label/stock_view.xml 1970-01-01 00:00:00 +0000 |
1056 | +++ base_delivery_carrier_label/stock_view.xml 2014-01-15 13:14:41 +0000 |
1057 | @@ -0,0 +1,55 @@ |
1058 | +<?xml version="1.0" encoding="UTF-8"?> |
1059 | +<openerp> |
1060 | + <data> |
1061 | + <!-- From DELIVERY module on STOCK.PICKING --> |
1062 | + <!-- FORM --> |
1063 | + <record id="view_picking_out_form" model="ir.ui.view"> |
1064 | + <field name="name">delivery.stock.picking.out.form</field> |
1065 | + <field name="model">stock.picking.out</field> |
1066 | + <field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form"/> |
1067 | + <field name="arch" type="xml"> |
1068 | + <field name="state" position="before"> |
1069 | + <button name="action_generate_carrier_label" states="assigned,confirmed,draft" string="Create Shipping Label" type="object"/> |
1070 | + </field> |
1071 | + <field name="carrier_id" position="attributes"> |
1072 | + <attribute name="on_change">carrier_id_change(carrier_id, context)</attribute> |
1073 | + </field> |
1074 | + <notebook position='inside'> |
1075 | + <page name="carrier" string="Carrier Info"> |
1076 | + <separator string="Delivery"/> |
1077 | + <field name="carrier_type"/> |
1078 | + <field name="carrier_code"/> |
1079 | + <separator string="Options"/> |
1080 | + <field name="option_ids" nolabel="1" |
1081 | + on_change="option_ids_change(option_ids, carrier_id, context)"/> |
1082 | + </page> |
1083 | + </notebook> |
1084 | + </field> |
1085 | + </record> |
1086 | + |
1087 | + <!-- From DELIVERY module on STOCK.PICKING --> |
1088 | + <!-- FORM --> |
1089 | + <record id="view_picking_in_form" model="ir.ui.view"> |
1090 | + <field name="name">delivery.stock.picking.in.form</field> |
1091 | + <field name="model">stock.picking.in</field> |
1092 | + <field name="inherit_id" ref="delivery.view_picking_withcarrier_in_form"/> |
1093 | + <field name="arch" type="xml"> |
1094 | + <field name="state" position="before"> |
1095 | + <button name="action_generate_carrier_label" states="assigned,confirmed,draft" string="Create Return Label" type="object"/> |
1096 | + </field> |
1097 | + <notebook position='inside'> |
1098 | + <page name="carrier" string="Carrier Info"> |
1099 | + <separator string="Delivery"/> |
1100 | + <field name="carrier_id" on_change="carrier_id_change(carrier_id, context)"/> |
1101 | + <field name="carrier_type"/> |
1102 | + <field name="carrier_code"/> |
1103 | + <separator string="Options"/> |
1104 | + <field name="option_ids" nolabel="1" |
1105 | + on_change="option_ids_change(option_ids, carrier_id, context)"/> |
1106 | + </page> |
1107 | + </notebook> |
1108 | + </field> |
1109 | + </record> |
1110 | + |
1111 | + </data> |
1112 | +</openerp> |
Thanks!
I pushed some change regarding the pep-8 and pep-257 (docstrings).
On this change:
I think we shouldn't set the tracking number readonly once the picking is done.
My rationale: if it makes sense for carriers which get the tracking number from the API, one may still want to handle some carrier manually and would still need to edit the field afterwards.
pdf_list is not used, and a semantic detail: not only pdf could be returned (zpl for instance):
pdf_list = [] single_ label()
pdf_ list.append( pdf)
for pick in pickings:
pdf = pick.generate_
In the access rights files, shouldn't it be stock.group_ stock_user and stock.group_ stock_manager instead of sales user / manager?