Merge lp:~vauxoo/openerp-venezuela-localization/ovl70-imex-context-rev-kty into lp:openerp-venezuela-localization

Proposed by Katherine Zaoral (Vauxoo)
Status: Merged
Merged at revision: 879
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/ovl70-imex-context-rev-kty
Merge into: lp:openerp-venezuela-localization
Diff against target: 168 lines (+35/-23)
3 files modified
l10n_ve_imex/model/customs_form.py (+22/-15)
l10n_ve_imex/model/customs_form_config.py (+3/-2)
l10n_ve_imex/model/invoice.py (+10/-6)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/ovl70-imex-context-rev-kty
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Approve
Review via email: mp+169427@code.launchpad.net

Commit message

[MERGE] change context into l10n_ve_imex for properly use.

To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_imex/model/customs_form.py'
2--- l10n_ve_imex/model/customs_form.py 2013-05-10 21:24:05 +0000
3+++ l10n_ve_imex/model/customs_form.py 2013-06-14 13:45:37 +0000
4@@ -148,6 +148,7 @@
5 cfl_ids.imex_tax_line and get debit account from account_tax model
6 """
7 lines = []
8+ context = context or {}
9 company_id = context.get('f86_company_id')
10 f86_cfg = context.get('f86_config')
11
12@@ -189,9 +190,8 @@
13 return lines
14
15 def create_account_move(self, cr, uid, ids, context=None):
16- if context is None:
17- context = {}
18- so_brw = self.browse(cr, uid, ids, context={})
19+ context = context or {}
20+ so_brw = self.browse(cr, uid, ids, context=context)
21 for f86 in so_brw:
22 if f86.move_id: # ~ The move is already done, nothing to do
23 return []
24@@ -201,7 +201,8 @@
25 cr, uid, uid, context=context).company_id.id
26 company = self.pool.get('res.company').browse(cr, uid, company_id,
27 context=context)
28- cfg_id = obj_cfg.search(cr, uid, [('company_id', '=', company_id)])
29+ cfg_id = obj_cfg.search(cr, uid, [('company_id', '=', company_id)],
30+ context=context)
31 if cfg_id:
32 f86_cfg = obj_cfg.browse(cr, uid, cfg_id[0], context=context)
33 else:
34@@ -227,38 +228,44 @@
35 str_inv = _('\n\tSupplier: %-40s Reference: %s') % \
36 (inv.partner_id.name, inv.supplier_invoice_number)
37 move['narration'] = '%s%s' % (move['narration'], str_inv)
38- lines = self.create_account_move_lines(cr, uid, f86, context)
39+ lines = self.create_account_move_lines(cr, uid, f86,
40+ context=context)
41 if lines:
42 move.update({'line_id': lines})
43- move_id = obj_move.create(cr, uid, move, context)
44+ move_id = obj_move.create(cr, uid, move, context=context)
45 obj_move.post(cr, uid, [move_id], context=context)
46 if move_id:
47 move_ids.append(move_id)
48- self.write(cr, uid, f86.id, {'move_id': move_id}, context)
49+ self.write(cr, uid, f86.id, {'move_id': move_id},
50+ context=context)
51 return move_ids
52
53 def button_draft(self, cr, uid, ids, context=None):
54+ context = context or {}
55 vals = {'state': 'draft'}
56- return self.write(cr, uid, ids, vals, context)
57+ return self.write(cr, uid, ids, vals, context=context)
58
59 def button_open(self, cr, uid, ids, context=None):
60- self.create_account_move(cr, uid, ids, context)
61+ context = context or {}
62+ self.create_account_move(cr, uid, ids, context=context)
63 vals = {'state': 'open'}
64- return self.write(cr, uid, ids, vals, context)
65+ return self.write(cr, uid, ids, vals, context=context)
66
67 def button_done(self, cr, uid, ids, context=None):
68+ context = context or {}
69 vals = {'state': 'done'}
70- return self.write(cr, uid, ids, vals, context)
71+ return self.write(cr, uid, ids, vals, context=context)
72
73 def button_cancel(self, cr, uid, ids, context=None):
74+ context = context or {}
75 f86 = self.browse(cr, uid, ids[0], context=context)
76 f86_move_id = f86.move_id.id if f86 and f86.move_id else False
77 vals = {'state': 'cancel', 'move_id': 0}
78- res = self.write(cr, uid, ids, vals, context)
79+ res = self.write(cr, uid, ids, vals, context=context)
80 if f86_move_id:
81 self.pool.get('account.move').unlink(cr, uid, [f86_move_id],
82- context)
83- return self.write(cr, uid, ids, vals, context)
84+ context=context)
85+ return self.write(cr, uid, ids, vals, context=context)
86
87 def test_draft(self, cr, uid, ids, *args):
88 return True
89@@ -302,7 +309,7 @@
90 raise osv.except_osv(
91 _('Error!'),
92 _('Multiple operations not allowed'))
93- for f86 in self.browse(cr, uid, ids, context=None):
94+ for f86 in self.browse(cr, uid, ids, context={}):
95 #~ Validate account_move.state != draft
96 if f86.move_id and f86.move_id.state != 'draft':
97 raise osv.except_osv(
98
99=== modified file 'l10n_ve_imex/model/customs_form_config.py'
100--- l10n_ve_imex/model/customs_form_config.py 2013-04-29 17:17:15 +0000
101+++ l10n_ve_imex/model/customs_form_config.py 2013-06-14 13:45:37 +0000
102@@ -109,11 +109,12 @@
103 _description = ''
104 _order = 'sequence'
105
106- def name_get(self, cr, uid, ids, context):
107+ def name_get(self, cr, uid, ids, context=None):
108+ context = context or {}
109 if not len(ids):
110 return []
111 res = []
112- so_brw = self.browse(cr, uid, ids, context)
113+ so_brw = self.browse(cr, uid, ids, context=context)
114 for item in so_brw:
115 res.append((item.id, '[%s] %s - %s' % (
116 item.code, item.ref, item.name)))
117
118=== modified file 'l10n_ve_imex/model/invoice.py'
119--- l10n_ve_imex/model/invoice.py 2013-05-10 21:24:05 +0000
120+++ l10n_ve_imex/model/invoice.py 2013-06-14 13:45:37 +0000
121@@ -52,12 +52,13 @@
122 on Book"),
123 }
124
125- def on_change_customs_form_id(self, cr, uid, ids, customs_form_id):
126+ def on_change_customs_form_id(self, cr, uid, ids, customs_form_id, context=None):
127+ context = context or {}
128 res = {}
129 if customs_form_id:
130 imp = self.pool.get('customs.form').browse(cr, uid,
131 customs_form_id,
132- context=None)
133+ context=context)
134 res = {'value': {'num_import_form': imp.name,
135 'import_invo': imp.date_liq}}
136 return res
137@@ -118,12 +119,14 @@
138 #~ res = {'domain': {'invoice_id': [('id','in',invoices)]}}
139 #~ return res
140
141- def on_change_amount(self, cr, uid, ids, tax_id, base_amount, tax_amount):
142+ def on_change_amount(self, cr, uid, ids, tax_id, base_amount, tax_amount,
143+ context=None):
144 """ To autocompute base or tax, only for percent based taxes. """
145+ context = context or {}
146 res = {}
147 if tax_id:
148 obj_vat = self.pool.get('account.tax')
149- vat = obj_vat.browse(cr, uid, tax_id)
150+ vat = obj_vat.browse(cr, uid, tax_id, context=context)
151 if vat.type == 'percent':
152 if base_amount == 0 and tax_amount > 0:
153 base_amount = round(tax_amount / vat.amount, 2)
154@@ -138,11 +141,12 @@
155
156 return res
157
158- def on_change_invoice_id(self, cr, uid, ids, invoice_id):
159+ def on_change_invoice_id(self, cr, uid, ids, invoice_id, context=None):
160+ context = context or {}
161 res = {}
162 if invoice_id:
163 obj_inv = self.pool.get('account.invoice')
164- inv = obj_inv.browse(cr, uid, invoice_id)
165+ inv = obj_inv.browse(cr, uid, invoice_id, context=context)
166 res = {'value': {'partner_id': inv.partner_id.id,
167 'supplier_invoice_number': inv.supplier_invoice_number}}
168 return res