From c465fc06372ff4208da4ecd92d24b249ca49a772 Mon Sep 17 00:00:00 2001 From: David Beal Date: Mon, 9 Oct 2023 09:01:24 +0200 Subject: [PATCH] FIX facto_bpce: error field on move --- .../models/company.py | 4 +++- .../models/subrogation_receipt.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/account_factoring_receivable_balance_bpce/models/company.py b/account_factoring_receivable_balance_bpce/models/company.py index b90eac2..933f777 100644 --- a/account_factoring_receivable_balance_bpce/models/company.py +++ b/account_factoring_receivable_balance_bpce/models/company.py @@ -15,7 +15,9 @@ class ResCompany(models.Model): bpce_factor_code = fields.Char(size=6, help="N° de compte chez PBCE") bpce_start_date = fields.Date( - string="Start Date", help="No account move will be selected before this date" + string="Start Date", + tracking=True, + help="No account move will be selected before this date", ) def ui_configure_bpce_factoring_balance(self): diff --git a/account_factoring_receivable_balance_bpce/models/subrogation_receipt.py b/account_factoring_receivable_balance_bpce/models/subrogation_receipt.py index 900af3f..3d0897a 100644 --- a/account_factoring_receivable_balance_bpce/models/subrogation_receipt.py +++ b/account_factoring_receivable_balance_bpce/models/subrogation_receipt.py @@ -87,7 +87,8 @@ def _get_domain_for_factor( partner_selection_field=partner_selection_field, currency=currency, ) - domain = [("date", ">=", self.env.user.company_id.bpce_start_date)] + domain + if self.env.user.company_id.bpce_start_date: + domain = [("date", ">=", self.env.user.company_id.bpce_start_date)] + domain return domain def _get_bpce_header(self): @@ -125,9 +126,10 @@ def _get_bpce_body(self): for line in self.line_ids: move = line.move_id partner = line.move_id.partner_id.commercial_partner_id + if not partner: + raise UserError(f"Pas de partenaire sur la pièce {line.move_id}") sequence += 1 name = pad(move.name, 30, position="left") - # piece = pad(move.name, 30, position="left") p_type = get_type_piece(move) total = move.amount_total_in_currency_signed info = { @@ -194,8 +196,8 @@ def get_type_piece(move): lambda s: s.account_id.group_id == s.env.ref("l10n_fr.1_pcg_411") ) for line in lines: - if max(line.debit, line.credit) == move.debit: - if line.debit == move.debit: + if max(line.debit, line.credit) == move.amount_total: + if line.debit == move.amount_total: od_type = "D" else: od_type = "C"