Merge lp:~openbig/bigconsulting/product_ean13_generator into lp:bigconsulting
- product_ean13_generator
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 11 |
Proposed branch: | lp:~openbig/bigconsulting/product_ean13_generator |
Merge into: | lp:bigconsulting |
Diff against target: |
552 lines (+489/-0) 11 files modified
product_ean13_generator/__init__.py (+27/-0) product_ean13_generator/__terp__.py (+48/-0) product_ean13_generator/product_ean13_generator.py (+57/-0) product_ean13_generator/product_ean13_generator_report.xml (+6/-0) product_ean13_generator/product_ean13_generator_sequence.xml (+53/-0) product_ean13_generator/product_ean13_generator_wizard.xml (+11/-0) product_ean13_generator/report/__init__.py (+25/-0) product_ean13_generator/report/product_ean_generator_report.rml (+121/-0) product_ean13_generator/report/report_product_ean_sequencer.py (+35/-0) product_ean13_generator/wizard/__init__.py (+25/-0) product_ean13_generator/wizard/generator_ean13.py (+81/-0) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/product_ean13_generator |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+26668@code.launchpad.net |
Commit message
Description of the change
Created new module product_
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'product_ean13_generator' |
2 | === added file 'product_ean13_generator/__init__.py' |
3 | --- product_ean13_generator/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ product_ean13_generator/__init__.py 2010-06-03 06:53:20 +0000 |
5 | @@ -0,0 +1,27 @@ |
6 | +# -*- encoding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved. |
11 | +# $Id$ |
12 | +# |
13 | +# This program is free software: you can redistribute it and/or modify |
14 | +# it under the terms of the GNU General Public License as published by |
15 | +# the Free Software Foundation, either version 3 of the License, or |
16 | +# (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU General Public License |
24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | +# |
26 | +############################################################################## |
27 | + |
28 | +import product_ean13_generator |
29 | +import wizard |
30 | +import report |
31 | + |
32 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
33 | \ No newline at end of file |
34 | |
35 | === added file 'product_ean13_generator/__terp__.py' |
36 | --- product_ean13_generator/__terp__.py 1970-01-01 00:00:00 +0000 |
37 | +++ product_ean13_generator/__terp__.py 2010-06-03 06:53:20 +0000 |
38 | @@ -0,0 +1,48 @@ |
39 | +# -*- encoding: utf-8 -*- |
40 | +############################################################################## |
41 | +# |
42 | +# OpenERP, Open Source Management Solution |
43 | +# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved. |
44 | +# $Id$ |
45 | +# |
46 | +# This program is free software: you can redistribute it and/or modify |
47 | +# it under the terms of the GNU General Public License as published by |
48 | +# the Free Software Foundation, either version 3 of the License, or |
49 | +# (at your option) any later version. |
50 | +# |
51 | +# This program is distributed in the hope that it will be useful, |
52 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
53 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
54 | +# GNU General Public License for more details. |
55 | +# |
56 | +# You should have received a copy of the GNU General Public License |
57 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
58 | +# |
59 | +############################################################################## |
60 | + |
61 | +{ |
62 | + "name" : "Product EAN13 Generator", |
63 | + "version" : "1.0", |
64 | + "author" : "Big Consulting", |
65 | + "website" : "http://www.openbig.org", |
66 | + "category" : "", |
67 | + "description": """ |
68 | + * Adds a wizard on product form to generate valid EAN13 product codes. |
69 | + * By default EAN13 will be generated with german country code (404) and 13341 as company code. |
70 | + Each company should this values on administration/sequences to addecuate to his country and company code. |
71 | + """, |
72 | + "license" : "GPL-3", |
73 | + "depends" : ["base","product",], |
74 | + "init_xml" : [], |
75 | + "update_xml" : [ |
76 | + "product_ean13_generator_sequence.xml", |
77 | + "product_ean13_generator_wizard.xml", |
78 | + "product_ean13_generator_report.xml" |
79 | + ], |
80 | + "active": False, |
81 | + "installable": True |
82 | +} |
83 | + |
84 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
85 | + |
86 | + |
87 | |
88 | === added file 'product_ean13_generator/product_ean13_generator.py' |
89 | --- product_ean13_generator/product_ean13_generator.py 1970-01-01 00:00:00 +0000 |
90 | +++ product_ean13_generator/product_ean13_generator.py 2010-06-03 06:53:20 +0000 |
91 | @@ -0,0 +1,57 @@ |
92 | +# -*- encoding: utf-8 -*- |
93 | +############################################################################## |
94 | +# |
95 | +# OpenERP, Open Source Management Solution |
96 | +# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. |
97 | +# Jordi Esteve <jesteve@zikzakmedia.com> |
98 | +# $Id$ |
99 | +# |
100 | +# This program is free software: you can redistribute it and/or modify |
101 | +# it under the terms of the GNU General Public License as published by |
102 | +# the Free Software Foundation, either version 3 of the License, or |
103 | +# (at your option) any later version. |
104 | +# |
105 | +# This program is distributed in the hope that it will be useful, |
106 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
107 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
108 | +# GNU General Public License for more details. |
109 | +# |
110 | +# You should have received a copy of the GNU General Public License |
111 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
112 | +# |
113 | +############################################################################## |
114 | + |
115 | +from osv import osv, fields |
116 | +from tools.translate import _ |
117 | + |
118 | +class ir_sequence(osv.osv): |
119 | + |
120 | + _inherit = 'ir.sequence' |
121 | + _columns = { |
122 | + 'number_max': fields.char('Max. Number',size=64,), |
123 | + 'warning_number': fields.char('Warning ab',size=64,), |
124 | + } |
125 | + |
126 | + def get_id(self, cr, uid, sequence_id, test='id=%s', context={}): |
127 | + if test not in ('id=%s', 'code=%s'): |
128 | + raise ValueError('invalid test') |
129 | + cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) |
130 | + res = cr.dictfetchone() |
131 | + ean_nr = self.browse(cr, uid, res['id'], context=context) |
132 | + sequence = super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context) |
133 | + code = 'generator.ean13' |
134 | + |
135 | + if ean_nr.code == code: |
136 | + number = ean_nr.number_max |
137 | + check_seq = sequence[8:] |
138 | + if check_seq >= ean_nr.warning_number: |
139 | + obj = self.pool.get("ir.actions.server") |
140 | + action_name = "EAN Generator Action" |
141 | + id = obj.search(cr, uid, [('name',"ilike",action_name)]) |
142 | + context.update({'active_id':res['id']}) |
143 | + obj.run(cr, uid, id, context) |
144 | + return sequence |
145 | + |
146 | +ir_sequence() |
147 | + |
148 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
149 | \ No newline at end of file |
150 | |
151 | === added file 'product_ean13_generator/product_ean13_generator_report.xml' |
152 | --- product_ean13_generator/product_ean13_generator_report.xml 1970-01-01 00:00:00 +0000 |
153 | +++ product_ean13_generator/product_ean13_generator_report.xml 2010-06-03 06:53:20 +0000 |
154 | @@ -0,0 +1,6 @@ |
155 | +<?xml version="1.0" encoding="utf-8"?> |
156 | +<openerp> |
157 | + <data> |
158 | + <report auto="False" id="report_product_ean_generator" model="product.product" name="ean.generator" rml="product_ean13_generator/report/product_ean_generator_report.rml" string="EAN13 Report" header="False"/> |
159 | + </data> |
160 | +</openerp> |
161 | |
162 | === added file 'product_ean13_generator/product_ean13_generator_sequence.xml' |
163 | --- product_ean13_generator/product_ean13_generator_sequence.xml 1970-01-01 00:00:00 +0000 |
164 | +++ product_ean13_generator/product_ean13_generator_sequence.xml 2010-06-03 06:53:20 +0000 |
165 | @@ -0,0 +1,53 @@ |
166 | +<?xml version="1.0" encoding="utf-8"?> |
167 | +<openerp> |
168 | + <data noupdate="1"> |
169 | + |
170 | + # |
171 | + # Sequences for product code |
172 | + # |
173 | + |
174 | + <record model="ir.sequence.type" id="seq_type_ean13_seq"> |
175 | + <field name="name">Ean13 Generator</field> |
176 | + <field name="code">generator.ean13</field> |
177 | + </record> |
178 | + <record model="ir.sequence" id="seq_ean13_seq"> |
179 | + <field name="name">Ean13 Sequence Generator</field> |
180 | + <field name="code">generator.ean13</field> |
181 | + <field name="prefix">40413341</field> |
182 | + <field name="padding">4</field> |
183 | + <field name="number_next">2763</field> |
184 | + <field name="number_max">2906</field> |
185 | + <field name="warning_number">2890</field> |
186 | + </record> |
187 | + |
188 | + <record id="ir_actions_server_seq" model="ir.actions.server"> |
189 | + <field eval="5" name="sequence"/> |
190 | + <field eval=""""Hello,\n |
191 | + EAN next number reached up to warning number, please modify EAN13 sequence."""" name="message"/> |
192 | + <field eval=""""EAN next number reached up to warning number"""" name="subject"/> |
193 | + <field eval=""""email"""" name="state"/> |
194 | + <field eval=""""ir.actions.server"""" name="type"/> |
195 | + <field eval=""""admin@example.com"""" name="email"/> |
196 | + <field name="model_id" ref="base.model_ir_sequence"/> |
197 | + <field eval=""""True"""" name="condition"/> |
198 | + <field eval=""""EAN Generator Action"""" name="name"/> |
199 | + </record> |
200 | + |
201 | + <record model="ir.ui.view" id="view_sale_order_line_tree_direct_delivery"> |
202 | + <field name="name">ir.sequence.form</field> |
203 | + <field name="model">ir.sequence</field> |
204 | + <field name="inherit_id" ref="base.sequence_view" /> |
205 | + <field name="type">form</field> |
206 | + <field name="arch" type="xml"> |
207 | + <field name="number_next" position="after"> |
208 | + <group col="4" colspan="4" attrs="{'invisible':[('code','!=','generator.ean13')]}"> |
209 | + <separator col="4" colspan="4" string="EAN Number Configuration"/> |
210 | + <field name="number_max" /> |
211 | + <field name="warning_number"/> |
212 | + </group> |
213 | + </field> |
214 | + </field> |
215 | + </record> |
216 | + |
217 | + </data> |
218 | +</openerp> |
219 | |
220 | === added file 'product_ean13_generator/product_ean13_generator_wizard.xml' |
221 | --- product_ean13_generator/product_ean13_generator_wizard.xml 1970-01-01 00:00:00 +0000 |
222 | +++ product_ean13_generator/product_ean13_generator_wizard.xml 2010-06-03 06:53:20 +0000 |
223 | @@ -0,0 +1,11 @@ |
224 | +<?xml version="1.0" encoding="utf-8"?> |
225 | +<openerp> |
226 | + <data> |
227 | + <wizard |
228 | + string="Generate Valid EAN13" |
229 | + model="product.product" |
230 | + name="product_ean13_generator.generator_ean13" |
231 | + menu="True" |
232 | + id="id_generator_ean13"/> |
233 | + </data> |
234 | +</openerp> |
235 | |
236 | === added directory 'product_ean13_generator/report' |
237 | === added file 'product_ean13_generator/report/__init__.py' |
238 | --- product_ean13_generator/report/__init__.py 1970-01-01 00:00:00 +0000 |
239 | +++ product_ean13_generator/report/__init__.py 2010-06-03 06:53:20 +0000 |
240 | @@ -0,0 +1,25 @@ |
241 | +# -*- encoding: utf-8 -*- |
242 | +############################################################################## |
243 | +# |
244 | +# OpenERP, Open Source Management Solution |
245 | +# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved. |
246 | +# $Id$ |
247 | +# |
248 | +# This program is free software: you can redistribute it and/or modify |
249 | +# it under the terms of the GNU General Public License as published by |
250 | +# the Free Software Foundation, either version 3 of the License, or |
251 | +# (at your option) any later version. |
252 | +# |
253 | +# This program is distributed in the hope that it will be useful, |
254 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
255 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
256 | +# GNU General Public License for more details. |
257 | +# |
258 | +# You should have received a copy of the GNU General Public License |
259 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
260 | +# |
261 | +############################################################################## |
262 | + |
263 | +import report_product_ean_sequencer |
264 | + |
265 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
266 | \ No newline at end of file |
267 | |
268 | === added file 'product_ean13_generator/report/product_ean_generator_report.rml' |
269 | --- product_ean13_generator/report/product_ean_generator_report.rml 1970-01-01 00:00:00 +0000 |
270 | +++ product_ean13_generator/report/product_ean_generator_report.rml 2010-06-03 06:53:20 +0000 |
271 | @@ -0,0 +1,121 @@ |
272 | +<?xml version="1.0"?> |
273 | +<document filename="test.pdf"> |
274 | + <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20"> |
275 | + <pageTemplate id="first"> |
276 | + <frame id="first" x1="15.0" y1="42.0" width="539" height="758"/> |
277 | + </pageTemplate> |
278 | + </template> |
279 | + <stylesheet> |
280 | + <blockTableStyle id="Standard_Outline"> |
281 | + <blockAlignment value="LEFT"/> |
282 | + <blockValign value="TOP"/> |
283 | + </blockTableStyle> |
284 | + <blockTableStyle id="Table1"> |
285 | + <blockAlignment value="LEFT"/> |
286 | + <blockValign value="TOP"/> |
287 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
288 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/> |
289 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
290 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/> |
291 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> |
292 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
293 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/> |
294 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="2,0" stop="2,-1"/> |
295 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/> |
296 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> |
297 | + <blockBackground colorName="#ffffff" start="0,0" stop="0,-1"/> |
298 | + <blockBackground colorName="#ffffff" start="1,0" stop="1,-1"/> |
299 | + <blockBackground colorName="#ffffff" start="2,0" stop="2,-1"/> |
300 | + </blockTableStyle> |
301 | + <blockTableStyle id="Table2"> |
302 | + <blockAlignment value="LEFT"/> |
303 | + <blockValign value="TOP"/> |
304 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
305 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
306 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/> |
307 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
308 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/> |
309 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="2,0" stop="2,-1"/> |
310 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> |
311 | + </blockTableStyle> |
312 | + <initialize> |
313 | + <paraStyle name="all" alignment="justify"/> |
314 | + </initialize> |
315 | + <paraStyle name="Standard" fontName="Times-Roman"/> |
316 | + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
317 | + <paraStyle name="Heading" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="12.0" spaceAfter="6.0"/> |
318 | + <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> |
319 | + <paraStyle name="Table Contents" fontName="Times-Roman"/> |
320 | + <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/> |
321 | + <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
322 | + <paraStyle name="Index" fontName="Times-Roman"/> |
323 | + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
324 | + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
325 | + <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
326 | + <paraStyle name="terp_default_Bold_12" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
327 | + <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
328 | + <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> |
329 | + <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> |
330 | + <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
331 | + <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> |
332 | + <paraStyle name="Footer" fontName="Times-Roman"/> |
333 | + <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> |
334 | + <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> |
335 | + <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> |
336 | + <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> |
337 | + <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> |
338 | + <paraStyle name="terp_default_left_10" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
339 | + <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
340 | + <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> |
341 | + <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
342 | + <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
343 | + <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
344 | + <paraStyle name="terp_default_1" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
345 | + <paraStyle name="terp_default_Right_9_Bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
346 | + <paraStyle name="terp_default_Italic" rightIndent="0.0" leftIndent="20.0" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
347 | + <paraStyle name="Preformatted Text" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/> |
348 | + <paraStyle name="terp_default_Centre_9_Bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
349 | + <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
350 | + <images/> |
351 | + </stylesheet> |
352 | + <story> |
353 | + <para style="terp_default_8"> |
354 | + <font color="white"> </font> |
355 | + </para> |
356 | + <para style="Standard"> |
357 | + <font color="white"> </font> |
358 | + </para> |
359 | + <blockTable colWidths="78.0,294.0,167.0" style="Table1"> |
360 | + <tr> |
361 | + <td> |
362 | + <para style="terp_default_Bold_12">Code</para> |
363 | + </td> |
364 | + <td> |
365 | + <para style="terp_default_Bold_12">Name</para> |
366 | + </td> |
367 | + <td> |
368 | + <para style="terp_default_Bold_12">EAN 13 Code</para> |
369 | + </td> |
370 | + </tr> |
371 | + </blockTable> |
372 | + <section> |
373 | + <para style="terp_default_1">[[repeatIn(objects,'o')]]</para> |
374 | + <blockTable colWidths="78.0,294.0,167.0" style="Table2"> |
375 | + <tr> |
376 | + <td> |
377 | + <para style="terp_default_left_10">[[ o.code ]]</para> |
378 | + </td> |
379 | + <td> |
380 | + <para style="terp_default_left_10">[[ o.name ]]</para> |
381 | + </td> |
382 | + <td> |
383 | + <para style="terp_default_left_10">[[ o.ean13 ]]</para> |
384 | + </td> |
385 | + </tr> |
386 | + </blockTable> |
387 | + </section> |
388 | + <para style="Standard"> |
389 | + <font color="white"> </font> |
390 | + </para> |
391 | + </story> |
392 | +</document> |
393 | |
394 | === added file 'product_ean13_generator/report/product_ean_generator_report.sxw' |
395 | Binary files product_ean13_generator/report/product_ean_generator_report.sxw 1970-01-01 00:00:00 +0000 and product_ean13_generator/report/product_ean_generator_report.sxw 2010-06-03 06:53:20 +0000 differ |
396 | === added file 'product_ean13_generator/report/report_product_ean_sequencer.py' |
397 | --- product_ean13_generator/report/report_product_ean_sequencer.py 1970-01-01 00:00:00 +0000 |
398 | +++ product_ean13_generator/report/report_product_ean_sequencer.py 2010-06-03 06:53:20 +0000 |
399 | @@ -0,0 +1,35 @@ |
400 | +# -*- encoding: utf-8 -*- |
401 | +############################################################################## |
402 | +# |
403 | +# OpenERP, Open Source Management Solution |
404 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
405 | +# $Id$ |
406 | +# |
407 | +# This program is free software: you can redistribute it and/or modify |
408 | +# it under the terms of the GNU General Public License as published by |
409 | +# the Free Software Foundation, either version 3 of the License, or |
410 | +# (at your option) any later version. |
411 | +# |
412 | +# This program is distributed in the hope that it will be useful, |
413 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
414 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
415 | +# GNU General Public License for more details. |
416 | +# |
417 | +# You should have received a copy of the GNU General Public License |
418 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
419 | +# |
420 | +############################################################################## |
421 | + |
422 | +import time |
423 | +from report import report_sxw |
424 | + |
425 | +class report_generator(report_sxw.rml_parse): |
426 | + def __init__(self, cr, uid, name, context): |
427 | + super(report_generator, self).__init__(cr, uid, name, context=context) |
428 | + self.localcontext.update({ |
429 | + 'time': time, |
430 | + }) |
431 | +report_sxw.report_sxw('report.ean.generator','product.product','addons/product_ean13_generator/report/product_ean_generator_report.rml',parser=report_generator) |
432 | + |
433 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
434 | + |
435 | |
436 | === added directory 'product_ean13_generator/wizard' |
437 | === added file 'product_ean13_generator/wizard/__init__.py' |
438 | --- product_ean13_generator/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
439 | +++ product_ean13_generator/wizard/__init__.py 2010-06-03 06:53:20 +0000 |
440 | @@ -0,0 +1,25 @@ |
441 | +# -*- encoding: utf-8 -*- |
442 | +############################################################################## |
443 | +# |
444 | +# OpenERP, Open Source Management Solution |
445 | +# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved. |
446 | +# $Id$ |
447 | +# |
448 | +# This program is free software: you can redistribute it and/or modify |
449 | +# it under the terms of the GNU General Public License as published by |
450 | +# the Free Software Foundation, either version 3 of the License, or |
451 | +# (at your option) any later version. |
452 | +# |
453 | +# This program is distributed in the hope that it will be useful, |
454 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
455 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
456 | +# GNU General Public License for more details. |
457 | +# |
458 | +# You should have received a copy of the GNU General Public License |
459 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
460 | +# |
461 | +############################################################################## |
462 | + |
463 | +import generator_ean13 |
464 | + |
465 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
466 | \ No newline at end of file |
467 | |
468 | === added file 'product_ean13_generator/wizard/generator_ean13.py' |
469 | --- product_ean13_generator/wizard/generator_ean13.py 1970-01-01 00:00:00 +0000 |
470 | +++ product_ean13_generator/wizard/generator_ean13.py 2010-06-03 06:53:20 +0000 |
471 | @@ -0,0 +1,81 @@ |
472 | +# -*- encoding: utf-8 -*- |
473 | +############################################################################## |
474 | +# |
475 | +# OpenERP, Open Source Management Solution |
476 | +# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved. |
477 | +# $Id$ |
478 | +# |
479 | +# This program is free software: you can redistribute it and/or modify |
480 | +# it under the terms of the GNU General Public License as published by |
481 | +# the Free Software Foundation, either version 3 of the License, or |
482 | +# (at your option) any later version. |
483 | +# |
484 | +# This program is distributed in the hope that it will be useful, |
485 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
487 | +# GNU General Public License for more details. |
488 | +# |
489 | +# You should have received a copy of the GNU General Public License |
490 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
491 | +# |
492 | +############################################################################## |
493 | + |
494 | +import wizard |
495 | +import pooler |
496 | +import string |
497 | +import math |
498 | +from tools.translate import _ |
499 | + |
500 | +ean13_generator_form = """<?xml version="1.0" encoding="utf-8"?> |
501 | +<form string="Create ean13"> |
502 | + <label string="Do you want to define ean codes for packaging? If yes,you have to define packaging list before starting the wizard" /> |
503 | +</form>""" |
504 | + |
505 | +ean13_generator_fields = {} |
506 | + |
507 | +def is_pair(x): |
508 | + return not x%2 |
509 | + |
510 | +def _generatorEan13(self, cr, uid, data, context): |
511 | + |
512 | + product_obj = pooler.get_pool(cr.dbname).get('product.product') |
513 | + sequence_obj = pooler.get_pool(cr.dbname).get('ir.sequence') |
514 | + packaging_obj = pooler.get_pool(cr.dbname).get('product.packaging') |
515 | + |
516 | + for product in product_obj.browse(cr, uid, data['ids'], context=context): |
517 | + ref = sequence_obj.get(cr, uid, 'generator.ean13') |
518 | + sum=0 |
519 | + for i in range(12): |
520 | + if is_pair(i): |
521 | + sum += int(ref[i]) |
522 | + else: |
523 | + sum += 3 * int(ref[i]) |
524 | + new_ean_cc = int(math.ceil(sum / 10.0) * 10 - sum) |
525 | + new_ean = ref + str(new_ean_cc) |
526 | + vals = {'ean13': new_ean} |
527 | + product_obj.write(cr, uid, [product.id], vals) |
528 | + for pack in product.packaging: |
529 | + vals = {'ean': new_ean} |
530 | + packaging_obj.write(cr, uid, [pack.id], vals) |
531 | + |
532 | + return {} |
533 | + |
534 | +class generate_ean13(wizard.interface): |
535 | + states = { |
536 | + 'init' : { |
537 | + 'actions' : [], |
538 | + 'result' : {'type' : 'form', |
539 | + 'arch' : ean13_generator_form, |
540 | + 'fields' : ean13_generator_fields, |
541 | + 'state' : [('end', 'Cancel'),('create', 'Generate ean13') ]} |
542 | + }, |
543 | + 'create' : { |
544 | + 'actions' : [], |
545 | + 'result' : {'type' : 'action', |
546 | + 'action' : _generatorEan13, |
547 | + 'state' : 'end'} |
548 | + }, |
549 | + } |
550 | +generate_ean13("product_ean13_generator.generator_ean13") |
551 | + |
552 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |