~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to validate_type_line_invoice/account_invoice.py

  • Committer: Nhomar Hernandez
  • Date: 2013-04-19 20:33:12 UTC
  • mfrom: (542.1.314 addons-vauxoo)
  • Revision ID: nhomar@gmail.com-20130419203312-o35v7dn79l6vur0t
[MERGE - PEP8 AND V7-MIG] All migrated to V7 Just
improved osv.osv => osv.Model, osv.osv_memory => osv.TransientModel
import inside openerp.* enviroment
Erased class instansiation no necesarry anymore in V7
AUTOPEP8 run, Left PEP8 long lines manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
24
#
25
25
##############################################################################
26
 
from osv import osv, fields
27
 
from tools.translate import _
28
 
 
29
 
class account_invoice(osv.osv):
 
26
from openerp.osv import osv, fields
 
27
from openerp.tools.translate import _
 
28
 
 
29
 
 
30
class account_invoice(osv.Model):
30
31
    _inherit = 'account.invoice'
31
 
    
 
32
 
32
33
    def action_move_create(self, cr, uid, ids, context=None):
33
 
        invoice_line_obj=self.pool.get('account.invoice.line')
34
 
        account_obj=self.pool.get('account.account')
 
34
        invoice_line_obj = self.pool.get('account.invoice.line')
 
35
        account_obj = self.pool.get('account.account')
35
36
        for id_ in ids:
36
 
            lines = invoice_line_obj.search(cr,uid,[('invoice_id','=',id_)])
 
37
            lines = invoice_line_obj.search(
 
38
                cr, uid, [('invoice_id', '=', id_)])
37
39
            for line in lines:
38
 
                id_account=invoice_line_obj.browse(cr,uid,line).account_id.id
39
 
                type_line=account_obj.browse(cr,uid,id_account).type
 
40
                id_account = invoice_line_obj.browse(
 
41
                    cr, uid, line).account_id.id
 
42
                type_line = account_obj.browse(cr, uid, id_account).type
40
43
                if type_line == 'receivable' or type_line == 'payable':
41
 
                    raise osv.except_osv(_('Error'), _("Type of account in line's must be differt to 'receivable' and 'payable'"))
42
 
            type_acc_invo=self.browse(cr,uid,id_).account_id.type
43
 
            type_invoice=self.browse(cr,uid,id_).type
44
 
            if (type_invoice == 'out_invoice' or type_invoice=='out_refound') and type_acc_invo != 'receivable':
45
 
                raise osv.except_osv(_('Error'), _("Type of account in invoice to Customer must be 'receivable'"))
46
 
            if (type_invoice == 'in_invoice' or type_invoice=='in_refound') and type_acc_invo != 'payable':
47
 
                raise osv.except_osv(_('Error'), _("Type of account in invoice to Partner must be 'payable'"))
 
44
                    raise osv.except_osv(_('Error'), _(
 
45
                        "Type of account in line's must be differt to 'receivable' and 'payable'"))
 
46
            type_acc_invo = self.browse(cr, uid, id_).account_id.type
 
47
            type_invoice = self.browse(cr, uid, id_).type
 
48
            if (type_invoice == 'out_invoice' or type_invoice == 'out_refound') and type_acc_invo != 'receivable':
 
49
                raise osv.except_osv(_('Error'), _(
 
50
                    "Type of account in invoice to Customer must be 'receivable'"))
 
51
            if (type_invoice == 'in_invoice' or type_invoice == 'in_refound') and type_acc_invo != 'payable':
 
52
                raise osv.except_osv(_('Error'), _(
 
53
                    "Type of account in invoice to Partner must be 'payable'"))
48
54
        return super(account_invoice, self).action_move_create(cr, uid, ids)
49
 
account_invoice()