~vauxoo/openerp-mexico-localization/account_invoice_tax_dev_juan_carlos

« back to all changes in this revision

Viewing changes to l10n_mx_import_info/stock.py

[MERGE][REF][l10n_mx_import_info] Add compatibility to OpenERP-6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from osv import osv
19
19
from osv import fields
20
20
from tools.translate import _
 
21
import release
21
22
 
22
23
 
23
24
class stock_tracking(osv.osv):
193
194
 
194
195
            if not inv_type:
195
196
                inv_type = self._get_invoice_type(picking)
 
197
            if release.version>=6.1:
 
198
                if inv_type in ('out_invoice', 'out_refund'):
 
199
                    account_id = partner.property_account_receivable.id
 
200
                    payment_term_id = picking.sale_id.payment_term.id
 
201
                else:
 
202
                    account_id = partner.property_account_payable.id
196
203
 
197
 
            if inv_type in ('out_invoice', 'out_refund'):
198
 
                account_id = partner.property_account_receivable.id
199
 
                payment_term_id = self._get_payment_term(cr, uid, picking)
 
204
                address_contact_id, address_invoice_id = \
 
205
                        self.pool.get('res.partner').address_get(cr, uid, [partner.id], ['contact', 'invoice']).values()
 
206
                address = address_obj.browse(cr, uid, address_contact_id, context=context)
200
207
            else:
201
 
                account_id = partner.property_account_payable.id
202
 
 
203
 
            address_contact_id, address_invoice_id = \
204
 
                    self._get_address_invoice(cr, uid, picking).values()
205
 
            address = address_obj.browse(cr, uid, address_contact_id, context=context)
206
 
 
 
208
                if inv_type in ('out_invoice', 'out_refund'):
 
209
                    account_id = partner.property_account_receivable.id
 
210
                    payment_term_id = self._get_payment_term(cr, uid, picking)
 
211
                else:
 
212
                    account_id = partner.property_account_payable.id
 
213
 
 
214
                address_contact_id, address_invoice_id = \
 
215
                        self._get_address_invoice(cr, uid, picking).values()
 
216
                address = address_obj.browse(cr, uid, address_contact_id, context=context)
 
217
            
207
218
            comment = self._get_comment_invoice(cr, uid, picking)
208
219
            if group and partner.id in invoices_group:
209
220
                invoice_id = invoices_group[partner.id]
223
234
                    'type': inv_type,
224
235
                    'account_id': account_id,
225
236
                    'partner_id': address.partner_id.id,
226
 
                    'address_invoice_id': address_invoice_id,
 
237
                    'address_invoice_id': address_invoice_id ,
227
238
                    'address_contact_id': address_contact_id,
228
239
                    'comment': comment,
229
240
                    'payment_term': payment_term_id,