From cac92e09bc7d7984595fad1b386f9a17098c6453 Mon Sep 17 00:00:00 2001 From: Thomas Winteler Date: Wed, 5 May 2021 16:47:14 +0200 Subject: [PATCH] [FIX] patch based on old repo --- .../models/account_payment_order.py | 24 ++++++++++++++++++- .../tests/test_account_payment_mode.py | 5 +++- account_payment_order/i18n/de.po | 5 ++++ .../models/account_invoice.py | 4 ++-- .../models/account_payment_order.py | 8 ++++++- .../views/account_payment_order.xml | 1 + .../wizard/account_payment_line_create.py | 11 ++++++--- .../tests/test_account_payment_partner.py | 15 ++++++++---- .../tests/test_account_payment_purchase.py | 4 +++- 9 files changed, 63 insertions(+), 14 deletions(-) diff --git a/account_banking_pain_base/models/account_payment_order.py b/account_banking_pain_base/models/account_payment_order.py index c82f1e7..689b1b3 100644 --- a/account_banking_pain_base/models/account_payment_order.py +++ b/account_banking_pain_base/models/account_payment_order.py @@ -4,6 +4,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from flectra import models, fields, api, _, tools +import flectra.release from flectra.exceptions import UserError from flectra.tools.safe_eval import safe_eval from datetime import datetime @@ -305,6 +306,11 @@ class AccountPaymentOrder(models.Model): initiating_party = etree.SubElement(parent_node, 'InitgPty') initiating_party_name = etree.SubElement(initiating_party, 'Nm') initiating_party_name.text = my_company_name + initiating_party_software = etree.SubElement(initiating_party, 'CtctDtls') + initiating_party_software_name = etree.SubElement(initiating_party_software, 'Nm') + initiating_party_software_name.text = 'Flectra Open Source ERP and CRM' + initiating_party_software_version = etree.SubElement(initiating_party_software, 'Othr') + initiating_party_software_version.text = 'Version '+flectra.release.version initiating_party_identifier = ( self.payment_mode_id.initiating_party_identifier or self.payment_mode_id.company_id.initiating_party_identifier) @@ -540,7 +546,23 @@ class AccountPaymentOrder(models.Model): creditor_reference = etree.SubElement( creditor_ref_information, 'CdtrRef') else: - if gen_args.get('structured_remittance_issuer', True): + if line.communication_type == 'QRR': + creditor_ref_info_type = etree.SubElement( + creditor_ref_information, 'Tp') + creditor_ref_info_type_or = etree.SubElement( + creditor_ref_info_type, 'CdOrPrtry') + creditor_ref_info_type_code = etree.SubElement( + creditor_ref_info_type_or, 'Prtry') + creditor_ref_info_type_code.text = 'QRR' + elif line.communication_type == 'SCOR': + creditor_ref_info_type = etree.SubElement( + creditor_ref_information, 'Tp') + creditor_ref_info_type_or = etree.SubElement( + creditor_ref_info_type, 'CdOrPrtry') + creditor_ref_info_type_code = etree.SubElement( + creditor_ref_info_type_or, 'Cd') + creditor_ref_info_type_code.text = 'SCOR' + elif gen_args.get('structured_remittance_issuer', True): creditor_ref_info_type = etree.SubElement( creditor_ref_information, 'Tp') creditor_ref_info_type_or = etree.SubElement( diff --git a/account_payment_mode/tests/test_account_payment_mode.py b/account_payment_mode/tests/test_account_payment_mode.py index 3faa480..ea2342d 100644 --- a/account_payment_mode/tests/test_account_payment_mode.py +++ b/account_payment_mode/tests/test_account_payment_mode.py @@ -22,7 +22,7 @@ class TestAccountPaymentMode(TransactionCase): self.company_2 = self.env['res.company'].create({ 'name': 'Company 2', }) - + self.env.user.company_ids = self.env.user.company_ids | self.company_2 self.journal_c1 = self._create_journal('J1', self.company) self.journal_c2 = self._create_journal('J2', self.company_2) self.journal_c3 = self._create_journal('J3', self.company) @@ -40,12 +40,15 @@ class TestAccountPaymentMode(TransactionCase): def _create_journal(self, name, company): # Create a cash account # Create a journal for cash account + original_company = self.env.user.company_id + self.env.user.company_id = company journal = self.journal_model.create({ 'name': name, 'code': name, 'type': 'bank', 'company_id': company.id, }) + self.env.user.company_id = original_company return journal def test_payment_mode_company_consistency_change(self): diff --git a/account_payment_order/i18n/de.po b/account_payment_order/i18n/de.po index e96949a..4128d4b 100644 --- a/account_payment_order/i18n/de.po +++ b/account_payment_order/i18n/de.po @@ -601,6 +601,11 @@ msgstr "" "Zahlungsposten bestätigen, dessen Zahlungsdatum vor dem Fälligkeitsdatum " "liegt." +#. module: account_payment_order +#: model:ir.model.fields,field_description:account_payment_order.field_account_payment_order_ignore_past_date +msgid "Ignore Past Date" +msgstr "Datum in der Vergangenheit belassen" + #. module: account_payment_order #: selection:account.payment.mode,default_date_prefered:0 #: selection:account.payment.order,date_prefered:0 diff --git a/account_payment_order/models/account_invoice.py b/account_payment_order/models/account_invoice.py index 9234a61..acbe5b2 100644 --- a/account_payment_order/models/account_invoice.py +++ b/account_payment_order/models/account_invoice.py @@ -105,12 +105,12 @@ class AccountInvoice(models.Model): count += 1 if new_payorder: inv.message_post(body=_( - '%d payment lines added to the new draft payment ' + '%s payment lines added to the new draft payment ' 'order %s which has been automatically created.') % (count, payorder.name)) else: inv.message_post(body=_( - '%d payment lines added to the existing draft ' + '%s payment lines added to the existing draft ' 'payment order %s.') % (count, payorder.name)) action = self.env['ir.actions.act_window'].for_xml_id( diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py index 1b7db2f..846e3c9 100644 --- a/account_payment_order/models/account_payment_order.py +++ b/account_payment_order/models/account_payment_order.py @@ -71,6 +71,12 @@ class AccountPaymentOrder(models.Model): ], string='Payment Execution Date Type', required=True, default='due', track_visibility='onchange', readonly=True, states={'draft': [('readonly', False)]}) + ignore_past_date = fields.Boolean( + string='Ignore Past Date', + readonly=True, + states={'draft': [('readonly', False)]}, + help='the payment date will not be set to today if enabled.', + ) date_scheduled = fields.Date( string='Payment Execution Date', readonly=True, states={'draft': [('readonly', False)]}, track_visibility='onchange', @@ -262,7 +268,7 @@ class AccountPaymentOrder(models.Model): else: requested_date = today # No payment date in the past - if requested_date < today: + if requested_date < today and not order.ignore_past_date: requested_date = today # inbound: check option no_debit_before_maturity if ( diff --git a/account_payment_order/views/account_payment_order.xml b/account_payment_order/views/account_payment_order.xml index 81f932d..47e9df8 100644 --- a/account_payment_order/views/account_payment_order.xml +++ b/account_payment_order/views/account_payment_order.xml @@ -46,6 +46,7 @@ + diff --git a/account_payment_order/wizard/account_payment_line_create.py b/account_payment_order/wizard/account_payment_line_create.py index b7b581b..9bb51d2 100644 --- a/account_payment_order/wizard/account_payment_line_create.py +++ b/account_payment_order/wizard/account_payment_line_create.py @@ -112,9 +112,14 @@ class AccountPaymentLineCreate(models.TransientModel): # Exclude lines that are already in a non-cancelled # and non-uploaded payment order; lines that are in a # uploaded payment order are proposed if they are not reconciled, - paylines = self.env['account.payment.line'].search([ - ('state', 'in', ('draft', 'open', 'generated')), - ('move_line_id', '!=', False)]) + if self.order_id.payment_mode_id.generate_move: + paylines = self.env['account.payment.line'].search([ + ('state', 'in', ('draft', 'open', 'generated')), + ('move_line_id', '!=', False)]) + else: + paylines = self.env['account.payment.line'].search([ + ('state', 'in', ('draft', 'open', 'generated', 'uploaded')), + ('move_line_id', '!=', False)]) if paylines: move_lines_ids = [payline.move_line_id.id for payline in paylines] domain += [('id', 'not in', move_lines_ids)] diff --git a/account_payment_partner/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index d180715..85c63ff 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -27,12 +27,15 @@ class TestAccountPaymentPartner(common.SavepointCase): cls.company_2 = cls.env['res.company'].create( {'name': 'Company 2'}, ) + cls.env.user.company_ids = cls.env.user.company_ids | cls.company_2 charts = cls.env['account.chart.template'].search([]) if charts: cls.chart = charts[0] else: raise ValidationError( _("No Chart of Account Template has been defined !")) + original_company = cls.env.user.company_id + cls.env.user.company_id = cls.company_2 cls.wizard = cls.env['wizard.multi.charts.accounts'].create({ 'company_id': cls.company_2.id, 'chart_template_id': cls.chart.id, @@ -43,7 +46,7 @@ class TestAccountPaymentPartner(common.SavepointCase): 'transfer_account_id': cls.chart.transfer_account_id.id, }) cls.wizard.execute() - + cls.env.user.company_id = original_company # refs cls.manual_out = cls.env.ref( 'account.account_payment_method_manual_out') @@ -65,7 +68,8 @@ class TestAccountPaymentPartner(common.SavepointCase): 'company_id': cls.company.id, 'bank_acc_number': '123456', }) - + original_company = cls.env.user.company_id + cls.env.user.company_id = cls.company_2.id cls.journal_c2 = cls.journal_model.create({ 'name': 'J2', 'code': 'J2', @@ -73,7 +77,7 @@ class TestAccountPaymentPartner(common.SavepointCase): 'company_id': cls.company_2.id, 'bank_acc_number': '552344', }) - + cls.env.user.company_id = original_company.id cls.supplier_payment_mode = cls.payment_mode_model.create({ 'name': 'Suppliers Bank 1', 'bank_account_link': 'variable', @@ -83,7 +87,7 @@ class TestAccountPaymentPartner(common.SavepointCase): 'fixed_journal_id': cls.journal_c1.id, 'variable_journal_ids': [(6, 0, [cls.journal_c1.id])] }) - + cls.env.user.company_id = cls.company_2.id cls.supplier_payment_mode_c2 = cls.payment_mode_model.create({ 'name': 'Suppliers Bank 2', 'bank_account_link': 'variable', @@ -92,7 +96,7 @@ class TestAccountPaymentPartner(common.SavepointCase): 'fixed_journal_id': cls.journal_c2.id, 'variable_journal_ids': [(6, 0, [cls.journal_c2.id])] }) - + cls.env.user.company_id = original_company.id cls.customer_payment_mode = cls.payment_mode_model.create({ 'name': 'Customers to Bank 1', 'bank_account_link': 'fixed', @@ -127,6 +131,7 @@ class TestAccountPaymentPartner(common.SavepointCase): force_company=cls.company_2.id).supplier_payment_mode_id = \ cls.supplier_payment_mode_c2 + cls.env.user.company_id = original_company.id cls.invoice_account = cls.env['account.account'].search( [('user_type_id', '=', cls.acct_type_payable.id), ('company_id', '=', cls.company.id)], diff --git a/account_payment_purchase/tests/test_account_payment_purchase.py b/account_payment_purchase/tests/test_account_payment_purchase.py index 2ee8dae..033b853 100644 --- a/account_payment_purchase/tests/test_account_payment_purchase.py +++ b/account_payment_purchase/tests/test_account_payment_purchase.py @@ -134,7 +134,9 @@ class TestAccountPaymentPurchase(common.SavepointCase): def test_procurement_buy_payment_mode(self): route = self.env.ref('purchase.route_warehouse0_buy') rule = self.env['procurement.rule'].search( - [('route_id', '=', route.id)], limit=1) + [('route_id', '=', route.id), + ('picking_type_id.warehouse_id.branch_id.company_id','=', self.env.user.company_id.id), + ], limit=1) rule._run_buy( product_id=self.mto_product, product_qty=1,