Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to put the invoice link and partner_id on the account_move ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 352
    Comment on it

    If you want to put the invoice link and partner_id on the account_move follow the following code :

     invoice_id = fields.Many2one('account.invoice', oldname="invoice")
        partner_id = fields.Many2one('res.partner', string='Partner', index=True, ondelete='restrict')
        user_type_id = fields.Many2one('account.account.type', related='account_id.user_type_id', index=True, store=True, oldname="user_type")
    
        _sql_constraints = [
            ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'),
            ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'),
        ]
    
        @api.multi
        @api.constrains('currency_id', 'account_id')
        def _check_currency(self):
            for line in self:
                if line.account_id.currency_id:
                    if not line.currency_id or line.currency_id.id != line.account_id.currency_id.id:
                        raise UserError(_('The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal.'))
    
        @api.multi
        @api.constrains('currency_id', 'amount_currency')
        def _check_currency_and_amount(self):
            for line in self:
                if (line.amount_currency and not line.currency_id):
                    raise UserError(_("You cannot create journal items with a secondary currency without filling both 'currency' and 'amount currency' field."))
    
        @api.multi
        @api.constrains('amount_currency')
        def _check_currency_amount(self):
            for line in self:
                if line.amount_currency:
                    if (line.amount_currency > 0.0 and line.credit > 0.0) or (line.amount_currency < 0.0 and line.debit > 0.0):
                        raise UserError(_('The amount expressed in the secondary currency must be positive when account is debited and negative when account is credited.'))
    
      @api.model
        def get_data_for_manual_reconciliation_widget(self, partner_ids, account_ids):
            """ Returns the data required for the invoices & payments matching of partners/accounts.
                If an argument is None, fetch all related reconciliations. Use [] to fetch nothing.
            """
            return {
                'customers': self.get_data_for_manual_reconciliation('partner', partner_ids, 'receivable'),
                'suppliers': self.get_data_for_manual_reconciliation('partner', partner_ids, 'payable'),
                'accounts': self.get_data_for_manual_reconciliation('account', account_ids),
            }
    

     

 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: