Fix bank deposits and add fields
Some checks failed
Update odoo 18 / update (push) Failing after 1m24s
Some checks failed
Update odoo 18 / update (push) Failing after 1m24s
This commit is contained in:
parent
9d5b9fb317
commit
49c2dc48d0
4
bross.py
4
bross.py
@ -26,7 +26,7 @@ headers = {
|
||||
|
||||
# BOOKING
|
||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241009-503875-1220777184", headers=headers) # Room move
|
||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241106-503875-1217522037", headers=headers) # Cancelled booking
|
||||
response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241106-503875-1217522037", headers=headers) # Cancelled booking
|
||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20240727-503875-1216958604", headers=headers)
|
||||
|
||||
# INVOICES
|
||||
@ -45,7 +45,7 @@ headers = {
|
||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/guests/9007199255607320/room-stays", headers=headers)
|
||||
|
||||
# ALL ROOMS
|
||||
response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms", headers=headers)
|
||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms", headers=headers)
|
||||
|
||||
|
||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms?roomTypeId=5020078", headers=headers)
|
||||
|
||||
@ -8,4 +8,5 @@ class BrosseBankAccount(models.Model):
|
||||
|
||||
account_number = fields.Char(string='Account Number', required=True)
|
||||
holder_name = fields.Char(string='Holder Name')
|
||||
currency_id = fields.Many2one('res.currency', string='Account Currency')
|
||||
bank_ids = fields.Many2many('brosse.bank', string='Banks')
|
||||
|
||||
@ -7,5 +7,9 @@ class BrosseBankDeposits(models.Model):
|
||||
|
||||
amount = fields.Monetary(string="Amount", currency_field='currency_id')
|
||||
currency_id = fields.Many2one('res.currency', string='Account Currency')
|
||||
description = fields.Char(string="Description")
|
||||
comment = fields.Text(string="Comment")
|
||||
partner_name = fields.Char(string="Partner Name")
|
||||
taxpayer_name = fields.Char(string="Taxpayer Name")
|
||||
|
||||
bank_account_id = fields.Many2one('brosse.bank.account', string="Bank Account")
|
||||
|
||||
@ -4,6 +4,7 @@ import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from datetime import datetime
|
||||
from odoo import models, fields, _
|
||||
from tbc_bank_integration_service_lib.client import TBCBankClient
|
||||
from odoo.exceptions import UserError
|
||||
@ -73,12 +74,14 @@ class BankMovements(models.Model):
|
||||
|
||||
def get_movements(self):
|
||||
client = self.env['bank.settings'].get_request_object()
|
||||
res = client.get_account_movements_by_date_range('111111', '2024-01-01T00:00:00.000', '2024-10-01T00:00:00.000')
|
||||
today_formatted_date = datetime.now().strftime('%Y-%m-%dT00:00:00.000')
|
||||
|
||||
res = client.get_account_movements_by_date_range('111111', '2024-01-01T00:00:00.000', today_formatted_date)
|
||||
self.create_or_update_raw_data(res, 'bank.raw.movements', res['data'])
|
||||
pages = math.ceil(int(res['data']['pager']['totalcount']) / int(res['data']['pager']['pagesize']))
|
||||
if pages > 1:
|
||||
for page in range(1, pages):
|
||||
res = client.get_account_movements_by_date_range_next_page('111111', page, 700, '2024-01-01T00:00:00.000', '2024-10-01T00:00:00.000')
|
||||
res = client.get_account_movements_by_date_range_next_page('111111', page, 700, '2024-01-01T00:00:00.000', today_formatted_date)
|
||||
self.create_or_update_raw_data(res, 'bank.raw.movements', res['data'])
|
||||
|
||||
def process_movements(self):
|
||||
@ -92,6 +95,15 @@ class BankMovements(models.Model):
|
||||
amount = movement['amount']['amount']
|
||||
currency = movement['amount']['currency']
|
||||
iban_code = account_number[4:6]
|
||||
description = movement['description']
|
||||
comment = movement['additionalInformation']
|
||||
partner_name = movement['partnerName']
|
||||
taxpayer_name = movement['taxpayerName']
|
||||
|
||||
if movement['debitCredit'] == '0':
|
||||
amount = float(amount) * -1
|
||||
|
||||
currency_id = self.env['res.currency'].search([('name', '=', currency)])
|
||||
|
||||
found_bank = self.env['brosse.bank'].search([('iban_code', '=', iban_code)])
|
||||
|
||||
@ -104,7 +116,9 @@ class BankMovements(models.Model):
|
||||
'iban_code': iban_code
|
||||
}).id
|
||||
|
||||
found_bank_account = self.env['brosse.bank.account'].search([('account_number', '=', account_number)])
|
||||
found_bank_account = self.env['brosse.bank.account'].search([
|
||||
('account_number', '=', account_number),
|
||||
('currency_id', '=', currency_id.id)])
|
||||
|
||||
if found_bank_account:
|
||||
bank_account_id = found_bank_account.id
|
||||
@ -112,13 +126,18 @@ class BankMovements(models.Model):
|
||||
bank_account_id = self.env['brosse.bank.account'].create({
|
||||
'bank_ids': [(4, bank_id)],
|
||||
'holder_name': account_name,
|
||||
'currency_id': currency_id.id,
|
||||
'account_number': account_number,
|
||||
}).id
|
||||
|
||||
self.env['brosse.bank.deposits'].create({
|
||||
'bank_account_id': bank_account_id,
|
||||
'amount': amount,
|
||||
'currency_id': self.env['res.currency'].search([('name', '=', currency)]).id
|
||||
'currency_id': currency_id.id,
|
||||
'description': description,
|
||||
'comment': comment,
|
||||
'partner_name': partner_name,
|
||||
'taxpayer_name': taxpayer_name
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<list>
|
||||
<field name="account_number"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="holder_name"/>
|
||||
</list>
|
||||
</field>
|
||||
@ -22,6 +23,7 @@
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="account_number"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="holder_name"/>
|
||||
<field name="bank_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
|
||||
@ -7,7 +7,11 @@
|
||||
<list string="Bank Deposits" editable="bottom">
|
||||
<field name="bank_account_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="currency_id" invisible='1'/>
|
||||
<field name="description" optional="show"/>
|
||||
<field name="comment" optional="show"/>
|
||||
<field name="partner_name" optional="show"/>
|
||||
<field name="taxpayer_name" optional="show"/>
|
||||
<field name="currency_id" column_invisible='1'/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user