23
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
##############################################################################
26
from osv import osv, fields
27
from tools.translate import _
29
class account_invoice(osv.osv):
26
from openerp.osv import osv, fields
27
from openerp.tools.translate import _
30
class account_invoice(osv.Model):
30
31
_inherit = 'account.invoice'
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')
36
lines = invoice_line_obj.search(cr,uid,[('invoice_id','=',id_)])
37
lines = invoice_line_obj.search(
38
cr, uid, [('invoice_id', '=', id_)])
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)