Merge lp:~openbig/bigconsulting/product_ean13_generator into lp:bigconsulting

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
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+26668@code.launchpad.net

Description of the change

Created new module product_ean13_generator, added wizard Generate Valid EAN13 which generate EAN code for 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
=== added directory 'product_ean13_generator'
=== added file 'product_ean13_generator/__init__.py'
--- product_ean13_generator/__init__.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/__init__.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,27 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved.
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import product_ean13_generator
24import wizard
25import report
26
27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file28\ No newline at end of file
129
=== added file 'product_ean13_generator/__terp__.py'
--- product_ean13_generator/__terp__.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/__terp__.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,48 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved.
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23{
24 "name" : "Product EAN13 Generator",
25 "version" : "1.0",
26 "author" : "Big Consulting",
27 "website" : "http://www.openbig.org",
28 "category" : "",
29 "description": """
30 * Adds a wizard on product form to generate valid EAN13 product codes.
31 * By default EAN13 will be generated with german country code (404) and 13341 as company code.
32 Each company should this values on administration/sequences to addecuate to his country and company code.
33 """,
34 "license" : "GPL-3",
35 "depends" : ["base","product",],
36 "init_xml" : [],
37 "update_xml" : [
38 "product_ean13_generator_sequence.xml",
39 "product_ean13_generator_wizard.xml",
40 "product_ean13_generator_report.xml"
41 ],
42 "active": False,
43 "installable": True
44}
45
46# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
47
48
049
=== added file 'product_ean13_generator/product_ean13_generator.py'
--- product_ean13_generator/product_ean13_generator.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/product_ean13_generator.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,57 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
6# Jordi Esteve <jesteve@zikzakmedia.com>
7# $Id$
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from osv import osv, fields
25from tools.translate import _
26
27class ir_sequence(osv.osv):
28
29 _inherit = 'ir.sequence'
30 _columns = {
31 'number_max': fields.char('Max. Number',size=64,),
32 'warning_number': fields.char('Warning ab',size=64,),
33 }
34
35 def get_id(self, cr, uid, sequence_id, test='id=%s', context={}):
36 if test not in ('id=%s', 'code=%s'):
37 raise ValueError('invalid test')
38 cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,))
39 res = cr.dictfetchone()
40 ean_nr = self.browse(cr, uid, res['id'], context=context)
41 sequence = super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context)
42 code = 'generator.ean13'
43
44 if ean_nr.code == code:
45 number = ean_nr.number_max
46 check_seq = sequence[8:]
47 if check_seq >= ean_nr.warning_number:
48 obj = self.pool.get("ir.actions.server")
49 action_name = "EAN Generator Action"
50 id = obj.search(cr, uid, [('name',"ilike",action_name)])
51 context.update({'active_id':res['id']})
52 obj.run(cr, uid, id, context)
53 return sequence
54
55ir_sequence()
56
57# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file58\ No newline at end of file
159
=== added file 'product_ean13_generator/product_ean13_generator_report.xml'
--- product_ean13_generator/product_ean13_generator_report.xml 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/product_ean13_generator_report.xml 2010-06-03 06:53:20 +0000
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
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"/>
5 </data>
6</openerp>
07
=== added file 'product_ean13_generator/product_ean13_generator_sequence.xml'
--- product_ean13_generator/product_ean13_generator_sequence.xml 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/product_ean13_generator_sequence.xml 2010-06-03 06:53:20 +0000
@@ -0,0 +1,53 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4
5 #
6 # Sequences for product code
7 #
8
9 <record model="ir.sequence.type" id="seq_type_ean13_seq">
10 <field name="name">Ean13 Generator</field>
11 <field name="code">generator.ean13</field>
12 </record>
13 <record model="ir.sequence" id="seq_ean13_seq">
14 <field name="name">Ean13 Sequence Generator</field>
15 <field name="code">generator.ean13</field>
16 <field name="prefix">40413341</field>
17 <field name="padding">4</field>
18 <field name="number_next">2763</field>
19 <field name="number_max">2906</field>
20 <field name="warning_number">2890</field>
21 </record>
22
23 <record id="ir_actions_server_seq" model="ir.actions.server">
24 <field eval="5" name="sequence"/>
25 <field eval="&quot;&quot;&quot;Hello,\n
26 EAN next number reached up to warning number, please modify EAN13 sequence.&quot;&quot;&quot;" name="message"/>
27 <field eval="&quot;&quot;&quot;EAN next number reached up to warning number&quot;&quot;&quot;" name="subject"/>
28 <field eval="&quot;&quot;&quot;email&quot;&quot;&quot;" name="state"/>
29 <field eval="&quot;&quot;&quot;ir.actions.server&quot;&quot;&quot;" name="type"/>
30 <field eval="&quot;&quot;&quot;admin@example.com&quot;&quot;&quot;" name="email"/>
31 <field name="model_id" ref="base.model_ir_sequence"/>
32 <field eval="&quot;&quot;&quot;True&quot;&quot;&quot;" name="condition"/>
33 <field eval="&quot;&quot;&quot;EAN Generator Action&quot;&quot;&quot;" name="name"/>
34 </record>
35
36 <record model="ir.ui.view" id="view_sale_order_line_tree_direct_delivery">
37 <field name="name">ir.sequence.form</field>
38 <field name="model">ir.sequence</field>
39 <field name="inherit_id" ref="base.sequence_view" />
40 <field name="type">form</field>
41 <field name="arch" type="xml">
42 <field name="number_next" position="after">
43 <group col="4" colspan="4" attrs="{'invisible':[('code','!=','generator.ean13')]}">
44 <separator col="4" colspan="4" string="EAN Number Configuration"/>
45 <field name="number_max" />
46 <field name="warning_number"/>
47 </group>
48 </field>
49 </field>
50 </record>
51
52 </data>
53</openerp>
054
=== added file 'product_ean13_generator/product_ean13_generator_wizard.xml'
--- product_ean13_generator/product_ean13_generator_wizard.xml 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/product_ean13_generator_wizard.xml 2010-06-03 06:53:20 +0000
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <wizard
5 string="Generate Valid EAN13"
6 model="product.product"
7 name="product_ean13_generator.generator_ean13"
8 menu="True"
9 id="id_generator_ean13"/>
10 </data>
11</openerp>
012
=== added directory 'product_ean13_generator/report'
=== added file 'product_ean13_generator/report/__init__.py'
--- product_ean13_generator/report/__init__.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/report/__init__.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,25 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved.
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import report_product_ean_sequencer
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file26\ No newline at end of file
127
=== added file 'product_ean13_generator/report/product_ean_generator_report.rml'
--- product_ean13_generator/report/product_ean_generator_report.rml 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/report/product_ean_generator_report.rml 2010-06-03 06:53:20 +0000
@@ -0,0 +1,121 @@
1<?xml version="1.0"?>
2<document filename="test.pdf">
3 <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="15.0" y1="42.0" width="539" height="758"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9 <blockTableStyle id="Standard_Outline">
10 <blockAlignment value="LEFT"/>
11 <blockValign value="TOP"/>
12 </blockTableStyle>
13 <blockTableStyle id="Table1">
14 <blockAlignment value="LEFT"/>
15 <blockValign value="TOP"/>
16 <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
17 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
18 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
19 <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
20 <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
21 <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
22 <lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
23 <lineStyle kind="LINEAFTER" colorName="#000000" start="2,0" stop="2,-1"/>
24 <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
25 <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
26 <blockBackground colorName="#ffffff" start="0,0" stop="0,-1"/>
27 <blockBackground colorName="#ffffff" start="1,0" stop="1,-1"/>
28 <blockBackground colorName="#ffffff" start="2,0" stop="2,-1"/>
29 </blockTableStyle>
30 <blockTableStyle id="Table2">
31 <blockAlignment value="LEFT"/>
32 <blockValign value="TOP"/>
33 <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
34 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
35 <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
36 <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
37 <lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
38 <lineStyle kind="LINEAFTER" colorName="#000000" start="2,0" stop="2,-1"/>
39 <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
40 </blockTableStyle>
41 <initialize>
42 <paraStyle name="all" alignment="justify"/>
43 </initialize>
44 <paraStyle name="Standard" fontName="Times-Roman"/>
45 <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
46 <paraStyle name="Heading" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="12.0" spaceAfter="6.0"/>
47 <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
48 <paraStyle name="Table Contents" fontName="Times-Roman"/>
49 <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
50 <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
51 <paraStyle name="Index" fontName="Times-Roman"/>
52 <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
53 <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
54 <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
55 <paraStyle name="terp_default_Bold_12" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
56 <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
57 <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
58 <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
59 <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
60 <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
61 <paraStyle name="Footer" fontName="Times-Roman"/>
62 <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
63 <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
64 <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
65 <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
66 <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
67 <paraStyle name="terp_default_left_10" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
68 <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
69 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
70 <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
71 <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
72 <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
73 <paraStyle name="terp_default_1" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
74 <paraStyle name="terp_default_Right_9_Bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
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"/>
76 <paraStyle name="Preformatted Text" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/>
77 <paraStyle name="terp_default_Centre_9_Bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
78 <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
79 <images/>
80 </stylesheet>
81 <story>
82 <para style="terp_default_8">
83 <font color="white"> </font>
84 </para>
85 <para style="Standard">
86 <font color="white"> </font>
87 </para>
88 <blockTable colWidths="78.0,294.0,167.0" style="Table1">
89 <tr>
90 <td>
91 <para style="terp_default_Bold_12">Code</para>
92 </td>
93 <td>
94 <para style="terp_default_Bold_12">Name</para>
95 </td>
96 <td>
97 <para style="terp_default_Bold_12">EAN 13 Code</para>
98 </td>
99 </tr>
100 </blockTable>
101 <section>
102 <para style="terp_default_1">[[repeatIn(objects,'o')]]</para>
103 <blockTable colWidths="78.0,294.0,167.0" style="Table2">
104 <tr>
105 <td>
106 <para style="terp_default_left_10">[[ o.code ]]</para>
107 </td>
108 <td>
109 <para style="terp_default_left_10">[[ o.name ]]</para>
110 </td>
111 <td>
112 <para style="terp_default_left_10">[[ o.ean13 ]]</para>
113 </td>
114 </tr>
115 </blockTable>
116 </section>
117 <para style="Standard">
118 <font color="white"> </font>
119 </para>
120 </story>
121</document>
0122
=== added file 'product_ean13_generator/report/product_ean_generator_report.sxw'
1Binary 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 differ123Binary 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
=== added file 'product_ean13_generator/report/report_product_ean_sequencer.py'
--- product_ean13_generator/report/report_product_ean_sequencer.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/report/report_product_ean_sequencer.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,35 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import time
24from report import report_sxw
25
26class report_generator(report_sxw.rml_parse):
27 def __init__(self, cr, uid, name, context):
28 super(report_generator, self).__init__(cr, uid, name, context=context)
29 self.localcontext.update({
30 'time': time,
31 })
32report_sxw.report_sxw('report.ean.generator','product.product','addons/product_ean13_generator/report/product_ean_generator_report.rml',parser=report_generator)
33
34# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
35
036
=== added directory 'product_ean13_generator/wizard'
=== added file 'product_ean13_generator/wizard/__init__.py'
--- product_ean13_generator/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/wizard/__init__.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,25 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved.
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import generator_ean13
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file26\ No newline at end of file
127
=== added file 'product_ean13_generator/wizard/generator_ean13.py'
--- product_ean13_generator/wizard/generator_ean13.py 1970-01-01 00:00:00 +0000
+++ product_ean13_generator/wizard/generator_ean13.py 2010-06-03 06:53:20 +0000
@@ -0,0 +1,81 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Ana Juaristi (http://openerpsite.com) All Rights Reserved.
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard
24import pooler
25import string
26import math
27from tools.translate import _
28
29ean13_generator_form = """<?xml version="1.0" encoding="utf-8"?>
30<form string="Create ean13">
31 <label string="Do you want to define ean codes for packaging? If yes,you have to define packaging list before starting the wizard" />
32</form>"""
33
34ean13_generator_fields = {}
35
36def is_pair(x):
37 return not x%2
38
39def _generatorEan13(self, cr, uid, data, context):
40
41 product_obj = pooler.get_pool(cr.dbname).get('product.product')
42 sequence_obj = pooler.get_pool(cr.dbname).get('ir.sequence')
43 packaging_obj = pooler.get_pool(cr.dbname).get('product.packaging')
44
45 for product in product_obj.browse(cr, uid, data['ids'], context=context):
46 ref = sequence_obj.get(cr, uid, 'generator.ean13')
47 sum=0
48 for i in range(12):
49 if is_pair(i):
50 sum += int(ref[i])
51 else:
52 sum += 3 * int(ref[i])
53 new_ean_cc = int(math.ceil(sum / 10.0) * 10 - sum)
54 new_ean = ref + str(new_ean_cc)
55 vals = {'ean13': new_ean}
56 product_obj.write(cr, uid, [product.id], vals)
57 for pack in product.packaging:
58 vals = {'ean': new_ean}
59 packaging_obj.write(cr, uid, [pack.id], vals)
60
61 return {}
62
63class generate_ean13(wizard.interface):
64 states = {
65 'init' : {
66 'actions' : [],
67 'result' : {'type' : 'form',
68 'arch' : ean13_generator_form,
69 'fields' : ean13_generator_fields,
70 'state' : [('end', 'Cancel'),('create', 'Generate ean13') ]}
71 },
72 'create' : {
73 'actions' : [],
74 'result' : {'type' : 'action',
75 'action' : _generatorEan13,
76 'state' : 'end'}
77 },
78 }
79generate_ean13("product_ean13_generator.generator_ean13")
80
81# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches