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

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 12
Proposed branch: lp:~openbig/bigconsulting/changes_to_generate_ean_for_packaging
Merge into: lp:bigconsulting
Diff against target: 18 lines (+9/-0)
1 file modified
product_ean13_generator/wizard/generator_ean13.py (+9/-0)
To merge this branch: bzr merge lp:~openbig/bigconsulting/changes_to_generate_ean_for_packaging
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+26802@code.launchpad.net

Description of the change

Added functionality to generate EAN code for packaging also.

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=== modified file 'product_ean13_generator/wizard/generator_ean13.py'
2--- product_ean13_generator/wizard/generator_ean13.py 2010-06-03 10:45:13 +0000
3+++ product_ean13_generator/wizard/generator_ean13.py 2010-06-04 13:22:20 +0000
4@@ -54,6 +54,15 @@
5 vals = {'ean13': new_ean}
6 product_obj.write(cr, uid, [product.id], vals)
7 for pack in product.packaging:
8+ ref = sequence_obj.get(cr, uid, 'generator.ean13')
9+ sum=0
10+ for i in range(12):
11+ if is_pair(i):
12+ sum += int(ref[i])
13+ else:
14+ sum += 3 * int(ref[i])
15+ new_ean_cc = int(math.ceil(sum / 10.0) * 10 - sum)
16+ new_ean = ref + str(new_ean_cc)
17 vals = {'ean': new_ean}
18 packaging_obj.write(cr, uid, [pack.id], vals)
19

Subscribers

People subscribed via source and target branches