|
|
|
@ -8,6 +8,37 @@ _logger = logging.getLogger(__name__)
|
|
|
|
|
class AccountJournal(models.Model):
|
|
|
|
|
_inherit = "account.journal"
|
|
|
|
|
|
|
|
|
|
def cash_in_or_out(self):
|
|
|
|
|
for journal in self:
|
|
|
|
|
journal.ensure_one()
|
|
|
|
|
|
|
|
|
|
# Create deposit
|
|
|
|
|
deposit = self.env['account.cash.deposit'].create({
|
|
|
|
|
'operation_type': 'order',
|
|
|
|
|
'date': fields.Date.today(),
|
|
|
|
|
'cash_journal_id': journal.id,
|
|
|
|
|
'bank_journal_id': journal.id,
|
|
|
|
|
'currency_id': self.env.company.currency_id.id
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# Add default lines
|
|
|
|
|
cash_units = self.env["cash.unit"].search(
|
|
|
|
|
[
|
|
|
|
|
("auto_create", "in", ("both", 'deposit')),
|
|
|
|
|
("currency_id", "=", deposit.currency_id.id),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
deposit.line_ids = [(0, 0, {
|
|
|
|
|
"cash_unit_id": cunit.id,
|
|
|
|
|
"qty": 0,
|
|
|
|
|
"currency_id": deposit.currency_id.id}) for cunit in cash_units ]
|
|
|
|
|
|
|
|
|
|
# Call form view
|
|
|
|
|
action = self.env['ir.actions.act_window']._for_xml_id('gn_cash.account_cash_inorout_action')
|
|
|
|
|
action['res_id'] = deposit.id
|
|
|
|
|
return action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_statement_line_from_payment(self, payment_id):
|
|
|
|
|
payment = self.env['account.payment'].browse(payment_id)
|
|
|
|
|
stmt_line_values = {
|
|
|
|
|