You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1.3 KiB

from odoo import fields, models, _
from odoo.exceptions import UserError, ValidationError,Warning
class CreateBankDeposit(models.TransientModel):
_name = 'opendons.createbankdeposit'
_description = 'Create a bank deposit form batchs selected'
def create_bank_deposit(self):
active_ids = self._context.get('active_ids', []) or []
if active_ids:
payments=self.env['opendons_payment_batch'].browse(active_ids)
for p in payments:
if p.state=='draft': raise Warning('the batch payment selected is not validated : operation cancelled')
if p.accounting_deposit_date: raise Warning('the batch payment selected was already deposited in accounting : operation cancelled')
if p.bank_deposit_date: raise Warning('the batch payment selected was already deposited in bank : operation cancelled')
#create bank deposit
vals={}
bd=self.env['opendons.bankdeposit'].create(vals)
for p in self.env['opendons_payment_batch'].browse(active_ids):
#add payment to bank deposit
bd.write({'payment_batch_ids':[(4,p.id)]})
#add bank deposit to payment
p.bankdeposit_id=bd.id
p.state='deposited_in_bank'
p.bank_deposit_date=bd.create_date