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