Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make Split Invoices in OpenERP(Odoo)?

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 464
    Comment on it

    If you want to make Split Invoices in OpenERP(Odoo) follow the below mentioned steps:
    Step-1Install 10n_ve_split_invoice module.
    Step-2 After that we have to customised 10n_ve_split_invoice module.
    In below example, I have custmozied .py file. You can directly copy the below python code in 10n_ve_split_invoice module.

    class account_invoice(osv.osv):
        _inherit = 'account.invoice'
    
        def split_invoice(self, cr, uid, ids):
            """ Split the invoice when the lines exceed the maximum set for the company
            """
            for inv in self.browse(cr, uid, ids):
                inv_id = False
                if inv.company_id.lines_invoice < 1:
                    raise osv.except_osv(_('Error !'), _('Please set an invoice lines value in:\nAdministration->Company->Configuration->Invoice lines'))
                if inv.type in ["out_invoice", "out_refund"]:
                    if len(inv.invoice_line) > inv.company_id.lines_invoice:
                        lst = []
                        invoice = self.read(cr, uid, inv.id, ['name', 'type', 'number', 'supplier_invoice_number', 'comment', 'date_due', 'partner_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id', 'period_id', "user_id"])
                        invoice.update({
                            'state': 'draft',
                            'number': False,
                            'invoice_line': [],
                            'tax_line': [],
                        })
                        # take the id part of the tuple returned for many2one fields
                        invoice.pop('id', None)
                        for field in ('partner_id',
                                'account_id', 'currency_id', 'payment_term', 'journal_id', 'period_id', 'user_id'):
                            invoice[field] = invoice[field] and invoice[field][0]
    
                        #~ if hasattr(inv,'sale_ids'):
                            #~ if self.browse(cr,uid,inv.id,context={}).sale_ids:
                            #~ invoice.update({
                            #~ 'sale_ids':[(6,0,[i.id for i in self.browse(cr,uid,inv.id,context={}).sale_ids])]
                            #~ })
    
                        inv_id = self.create(cr, uid, invoice)
                        cont = 0
                        lst = inv.invoice_line
                        while cont < inv.company_id.lines_invoice:
                            lst.pop(0)
                            cont += 1
                        for il in lst:
                            self.pool.get('account.invoice.line').write(cr, uid, il.id, {'invoice_id': inv_id})
                        self.button_compute(cr, uid, [inv.id], set_total=True)
                if inv_id:
                    self.button_compute(cr, uid, [inv_id], set_total=True)
    #                wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
            return True
    
        def action_date_assign(self, cr, uid, ids, *args):
            """ Return assigned dat
            """
            super(account_invoice, self).action_date_assign(cr, uid, ids, *args)
            self.split_invoice(cr, uid, ids)
            return True
    
    account_invoice()
     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: