[FIX] patch based on old repo

This commit is contained in:
Thomas Winteler 2021-05-05 16:47:14 +02:00 committed by Renzo Meister
parent 4cf91d9ea9
commit cac92e09bc
9 changed files with 63 additions and 14 deletions

View File

@ -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(

View File

@ -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):

View File

@ -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

View File

@ -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(

View File

@ -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 (

View File

@ -46,6 +46,7 @@
</group>
<group name="head-right">
<field name="date_prefered"/>
<field name="ignore_past_date"/>
<field name="date_scheduled"
attrs="{'invisible': [('date_prefered', '!=', 'fixed')], 'required': [('date_prefered', '=', 'fixed')]}"/>
<field name="date_generated"/>

View File

@ -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)]

View File

@ -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)],

View File

@ -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,