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
=== modified file 'l10n_ve_imex/model/customs_form.py'
--- l10n_ve_imex/model/customs_form.py 2013-05-10 21:24:05 +0000
+++ l10n_ve_imex/model/customs_form.py 2013-06-14 13:45:37 +0000
@@ -148,6 +148,7 @@
148 cfl_ids.imex_tax_line and get debit account from account_tax model148 cfl_ids.imex_tax_line and get debit account from account_tax model
149 """149 """
150 lines = []150 lines = []
151 context = context or {}
151 company_id = context.get('f86_company_id')152 company_id = context.get('f86_company_id')
152 f86_cfg = context.get('f86_config')153 f86_cfg = context.get('f86_config')
153154
@@ -189,9 +190,8 @@
189 return lines190 return lines
190191
191 def create_account_move(self, cr, uid, ids, context=None):192 def create_account_move(self, cr, uid, ids, context=None):
192 if context is None:193 context = context or {}
193 context = {}194 so_brw = self.browse(cr, uid, ids, context=context)
194 so_brw = self.browse(cr, uid, ids, context={})
195 for f86 in so_brw:195 for f86 in so_brw:
196 if f86.move_id: # ~ The move is already done, nothing to do196 if f86.move_id: # ~ The move is already done, nothing to do
197 return []197 return []
@@ -201,7 +201,8 @@
201 cr, uid, uid, context=context).company_id.id201 cr, uid, uid, context=context).company_id.id
202 company = self.pool.get('res.company').browse(cr, uid, company_id,202 company = self.pool.get('res.company').browse(cr, uid, company_id,
203 context=context)203 context=context)
204 cfg_id = obj_cfg.search(cr, uid, [('company_id', '=', company_id)])204 cfg_id = obj_cfg.search(cr, uid, [('company_id', '=', company_id)],
205 context=context)
205 if cfg_id:206 if cfg_id:
206 f86_cfg = obj_cfg.browse(cr, uid, cfg_id[0], context=context)207 f86_cfg = obj_cfg.browse(cr, uid, cfg_id[0], context=context)
207 else:208 else:
@@ -227,38 +228,44 @@
227 str_inv = _('\n\tSupplier: %-40s Reference: %s') % \228 str_inv = _('\n\tSupplier: %-40s Reference: %s') % \
228 (inv.partner_id.name, inv.supplier_invoice_number)229 (inv.partner_id.name, inv.supplier_invoice_number)
229 move['narration'] = '%s%s' % (move['narration'], str_inv)230 move['narration'] = '%s%s' % (move['narration'], str_inv)
230 lines = self.create_account_move_lines(cr, uid, f86, context)231 lines = self.create_account_move_lines(cr, uid, f86,
232 context=context)
231 if lines:233 if lines:
232 move.update({'line_id': lines})234 move.update({'line_id': lines})
233 move_id = obj_move.create(cr, uid, move, context)235 move_id = obj_move.create(cr, uid, move, context=context)
234 obj_move.post(cr, uid, [move_id], context=context)236 obj_move.post(cr, uid, [move_id], context=context)
235 if move_id:237 if move_id:
236 move_ids.append(move_id)238 move_ids.append(move_id)
237 self.write(cr, uid, f86.id, {'move_id': move_id}, context)239 self.write(cr, uid, f86.id, {'move_id': move_id},
240 context=context)
238 return move_ids241 return move_ids
239242
240 def button_draft(self, cr, uid, ids, context=None):243 def button_draft(self, cr, uid, ids, context=None):
244 context = context or {}
241 vals = {'state': 'draft'}245 vals = {'state': 'draft'}
242 return self.write(cr, uid, ids, vals, context)246 return self.write(cr, uid, ids, vals, context=context)
243247
244 def button_open(self, cr, uid, ids, context=None):248 def button_open(self, cr, uid, ids, context=None):
245 self.create_account_move(cr, uid, ids, context)249 context = context or {}
250 self.create_account_move(cr, uid, ids, context=context)
246 vals = {'state': 'open'}251 vals = {'state': 'open'}
247 return self.write(cr, uid, ids, vals, context)252 return self.write(cr, uid, ids, vals, context=context)
248253
249 def button_done(self, cr, uid, ids, context=None):254 def button_done(self, cr, uid, ids, context=None):
255 context = context or {}
250 vals = {'state': 'done'}256 vals = {'state': 'done'}
251 return self.write(cr, uid, ids, vals, context)257 return self.write(cr, uid, ids, vals, context=context)
252258
253 def button_cancel(self, cr, uid, ids, context=None):259 def button_cancel(self, cr, uid, ids, context=None):
260 context = context or {}
254 f86 = self.browse(cr, uid, ids[0], context=context)261 f86 = self.browse(cr, uid, ids[0], context=context)
255 f86_move_id = f86.move_id.id if f86 and f86.move_id else False262 f86_move_id = f86.move_id.id if f86 and f86.move_id else False
256 vals = {'state': 'cancel', 'move_id': 0}263 vals = {'state': 'cancel', 'move_id': 0}
257 res = self.write(cr, uid, ids, vals, context)264 res = self.write(cr, uid, ids, vals, context=context)
258 if f86_move_id:265 if f86_move_id:
259 self.pool.get('account.move').unlink(cr, uid, [f86_move_id],266 self.pool.get('account.move').unlink(cr, uid, [f86_move_id],
260 context)267 context=context)
261 return self.write(cr, uid, ids, vals, context)268 return self.write(cr, uid, ids, vals, context=context)
262269
263 def test_draft(self, cr, uid, ids, *args):270 def test_draft(self, cr, uid, ids, *args):
264 return True271 return True
@@ -302,7 +309,7 @@
302 raise osv.except_osv(309 raise osv.except_osv(
303 _('Error!'),310 _('Error!'),
304 _('Multiple operations not allowed'))311 _('Multiple operations not allowed'))
305 for f86 in self.browse(cr, uid, ids, context=None):312 for f86 in self.browse(cr, uid, ids, context={}):
306 #~ Validate account_move.state != draft313 #~ Validate account_move.state != draft
307 if f86.move_id and f86.move_id.state != 'draft':314 if f86.move_id and f86.move_id.state != 'draft':
308 raise osv.except_osv(315 raise osv.except_osv(
309316
=== modified file 'l10n_ve_imex/model/customs_form_config.py'
--- l10n_ve_imex/model/customs_form_config.py 2013-04-29 17:17:15 +0000
+++ l10n_ve_imex/model/customs_form_config.py 2013-06-14 13:45:37 +0000
@@ -109,11 +109,12 @@
109 _description = ''109 _description = ''
110 _order = 'sequence'110 _order = 'sequence'
111111
112 def name_get(self, cr, uid, ids, context):112 def name_get(self, cr, uid, ids, context=None):
113 context = context or {}
113 if not len(ids):114 if not len(ids):
114 return []115 return []
115 res = []116 res = []
116 so_brw = self.browse(cr, uid, ids, context)117 so_brw = self.browse(cr, uid, ids, context=context)
117 for item in so_brw:118 for item in so_brw:
118 res.append((item.id, '[%s] %s - %s' % (119 res.append((item.id, '[%s] %s - %s' % (
119 item.code, item.ref, item.name)))120 item.code, item.ref, item.name)))
120121
=== modified file 'l10n_ve_imex/model/invoice.py'
--- l10n_ve_imex/model/invoice.py 2013-05-10 21:24:05 +0000
+++ l10n_ve_imex/model/invoice.py 2013-06-14 13:45:37 +0000
@@ -52,12 +52,13 @@
52 on Book"),52 on Book"),
53 }53 }
5454
55 def on_change_customs_form_id(self, cr, uid, ids, customs_form_id):55 def on_change_customs_form_id(self, cr, uid, ids, customs_form_id, context=None):
56 context = context or {}
56 res = {}57 res = {}
57 if customs_form_id:58 if customs_form_id:
58 imp = self.pool.get('customs.form').browse(cr, uid,59 imp = self.pool.get('customs.form').browse(cr, uid,
59 customs_form_id,60 customs_form_id,
60 context=None)61 context=context)
61 res = {'value': {'num_import_form': imp.name,62 res = {'value': {'num_import_form': imp.name,
62 'import_invo': imp.date_liq}}63 'import_invo': imp.date_liq}}
63 return res64 return res
@@ -118,12 +119,14 @@
118 #~ res = {'domain': {'invoice_id': [('id','in',invoices)]}}119 #~ res = {'domain': {'invoice_id': [('id','in',invoices)]}}
119 #~ return res120 #~ return res
120121
121 def on_change_amount(self, cr, uid, ids, tax_id, base_amount, tax_amount):122 def on_change_amount(self, cr, uid, ids, tax_id, base_amount, tax_amount,
123 context=None):
122 """ To autocompute base or tax, only for percent based taxes. """124 """ To autocompute base or tax, only for percent based taxes. """
125 context = context or {}
123 res = {}126 res = {}
124 if tax_id:127 if tax_id:
125 obj_vat = self.pool.get('account.tax')128 obj_vat = self.pool.get('account.tax')
126 vat = obj_vat.browse(cr, uid, tax_id)129 vat = obj_vat.browse(cr, uid, tax_id, context=context)
127 if vat.type == 'percent':130 if vat.type == 'percent':
128 if base_amount == 0 and tax_amount > 0:131 if base_amount == 0 and tax_amount > 0:
129 base_amount = round(tax_amount / vat.amount, 2)132 base_amount = round(tax_amount / vat.amount, 2)
@@ -138,11 +141,12 @@
138141
139 return res142 return res
140143
141 def on_change_invoice_id(self, cr, uid, ids, invoice_id):144 def on_change_invoice_id(self, cr, uid, ids, invoice_id, context=None):
145 context = context or {}
142 res = {}146 res = {}
143 if invoice_id:147 if invoice_id:
144 obj_inv = self.pool.get('account.invoice')148 obj_inv = self.pool.get('account.invoice')
145 inv = obj_inv.browse(cr, uid, invoice_id)149 inv = obj_inv.browse(cr, uid, invoice_id, context=context)
146 res = {'value': {'partner_id': inv.partner_id.id,150 res = {'value': {'partner_id': inv.partner_id.id,
147 'supplier_invoice_number': inv.supplier_invoice_number}}151 'supplier_invoice_number': inv.supplier_invoice_number}}
148 return res152 return res