[MIG] account_payment_order: Migration to 14.0

This commit is contained in:
Jesús Alan Ramos Rodríguez
2020-11-14 10:36:28 -06:00
committed by Pedro M. Baeza
parent 28a35012b0
commit c65a93af5b
17 changed files with 108 additions and 107 deletions

View File

@@ -14,13 +14,13 @@ Account Payment Order
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
:target: https://github.com/OCA/bank-payment/tree/13.0/account_payment_order
:target: https://github.com/OCA/bank-payment/tree/14.0/account_payment_order
:alt: OCA/bank-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_payment_order
:target: https://translation.odoo-community.org/projects/bank-payment-14-0/bank-payment-14-0-account_payment_order
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/173/13.0
:target: https://runbot.odoo-community.org/runbot/173/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -66,7 +66,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_order%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_order%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -103,6 +103,9 @@ Contributors
* Raf Ven <raf.ven@dynapps.be>
* Andrea Stirpe <a.stirpe@onestein.nl>
* `Jarsa <https://www.jarsa.com.mx>`_:
* Alan Ramos <alan.ramos@jarsa.com.mx>
Maintainers
~~~~~~~~~~~
@@ -117,6 +120,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/13.0/account_payment_order>`_ project on GitHub.
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/14.0/account_payment_order>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -8,7 +8,7 @@
{
"name": "Account Payment Order",
"version": "13.0.1.4.1",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, "
"Therp BV, "

View File

@@ -116,9 +116,9 @@ class AccountMove(models.Model):
)
% (count, payorder.name)
)
action = self.env["ir.actions.act_window"].for_xml_id(
"account_payment_order",
"account_payment_order_%s_action" % action_payment_type,
action = self.env["ir.actions.act_window"]._for_xml_id(
"account_payment_order.account_payment_order_%s_action"
% action_payment_type,
)
if len(result_payorder_ids) == 1:
action.update(

View File

@@ -26,13 +26,11 @@ class AccountMoveLine(models.Model):
string="Payment lines",
)
@api.depends(
"move_id", "move_id.invoice_partner_bank_id", "move_id.payment_mode_id"
)
@api.depends("move_id", "move_id.partner_bank_id", "move_id.payment_mode_id")
def _compute_partner_bank_id(self):
for ml in self:
if (
ml.move_id.type in ("in_invoice", "in_refund")
ml.move_id.move_type in ("in_invoice", "in_refund")
and not ml.reconciled
and ml.payment_mode_id.payment_order_ok
and ml.account_id.internal_type in ("receivable", "payable")
@@ -41,7 +39,7 @@ class AccountMoveLine(models.Model):
for p_state in ml.payment_line_ids.mapped("state")
)
):
ml.partner_bank_id = ml.move_id.invoice_partner_bank_id.id
ml.partner_bank_id = ml.move_id.partner_bank_id.id
else:
ml.partner_bank_id = ml.partner_bank_id
@@ -60,11 +58,11 @@ class AccountMoveLine(models.Model):
communication_type = ref2comm_type[self.move_id.reference_type]
else:
if (
self.move_id.type in ("in_invoice", "in_refund")
self.move_id.move_type in ("in_invoice", "in_refund")
and self.move_id.ref
):
communication = self.move_id.ref
elif "out" in self.move_id.type:
elif "out" in self.move_id.move_type:
# Force to only put invoice number here
communication = self.move_id.name
if self.currency_id:

View File

@@ -7,22 +7,33 @@ from odoo import api, models
class AccountPayment(models.Model):
_inherit = "account.payment"
def _compute_journal_domain_and_types(self):
res = super(AccountPayment, self)._compute_journal_domain_and_types()
journal_domain = res.get("domain", [])
if self.payment_type == "inbound":
journal_domain.append(("inbound_payment_order_only", "=", False))
else:
journal_domain.append(("outbound_payment_order_only", "=", False))
res["domain"] = journal_domain
return res
def _get_default_journal(self):
res = super()._get_default_journal()
return res.filtered(lambda journal: not journal.inbound_payment_order_only)
@api.onchange("journal_id")
def _onchange_journal(self):
res = super(AccountPayment, self)._onchange_journal()
domains = res.get("domain")
if not domains:
return res
if domains.get("payment_method_id"):
domains["payment_method_id"].append(("payment_order_only", "!=", True))
@api.depends(
"payment_type",
"journal_id.inbound_payment_method_ids",
"journal_id.outbound_payment_method_ids",
)
def _compute_payment_method_fields(self):
res = super()._compute_payment_method_fields()
for pay in self:
if pay.payment_type == "inbound":
pay.available_payment_method_ids = (
pay.journal_id.inbound_payment_method_ids.filtered(
lambda m: not m.payment_order_only
)
)
else:
pay.available_payment_method_ids = (
pay.journal_id.outbound_payment_method_ids.filtered(
lambda m: not m.payment_order_only
)
)
pay.hide_payment_method = (
len(pay.available_payment_method_ids) == 1
and pay.available_payment_method_ids.code == "manual"
)
return res

View File

@@ -21,7 +21,7 @@ class AccountPaymentOrder(models.Model):
comodel_name="account.payment.mode",
required=True,
ondelete="restrict",
track_visibility="onchange",
tracking=True,
states={"draft": [("readonly", False)]},
)
payment_type = fields.Selection(
@@ -56,7 +56,7 @@ class AccountPaymentOrder(models.Model):
ondelete="restrict",
readonly=True,
states={"draft": [("readonly", False)]},
track_visibility="onchange",
tracking=True,
)
# The journal_id field is only required at confirm step, to
# allow auto-creation of payment order from invoice
@@ -78,7 +78,7 @@ class AccountPaymentOrder(models.Model):
readonly=True,
copy=False,
default="draft",
track_visibility="onchange",
tracking=True,
)
date_prefered = fields.Selection(
selection=[
@@ -89,7 +89,7 @@ class AccountPaymentOrder(models.Model):
string="Payment Execution Date Type",
required=True,
default="due",
track_visibility="onchange",
tracking=True,
readonly=True,
states={"draft": [("readonly", False)]},
)
@@ -97,7 +97,7 @@ class AccountPaymentOrder(models.Model):
string="Payment Execution Date",
readonly=True,
states={"draft": [("readonly", False)]},
track_visibility="onchange",
tracking=True,
help="Select a requested date of execution if you selected 'Due Date' "
"as the Payment Execution Date Type.",
)
@@ -458,7 +458,7 @@ class AccountPaymentOrder(models.Model):
vals.update({"date_maturity": bank_lines[0].date})
if self.payment_mode_id.offsetting_account == "bank_account":
account_id = self.journal_id.default_debit_account_id.id
account_id = self.journal_id.default_account_id.id
elif self.payment_mode_id.offsetting_account == "transfer_account":
account_id = self.payment_mode_id.transfer_account_id.id
partner_id = False
@@ -537,9 +537,9 @@ class AccountPaymentOrder(models.Model):
am_obj = self.env["account.move"]
mvals = self._prepare_move(blines)
move = am_obj.create(mvals)
blines.reconcile_payment_lines()
if post_move:
move.post()
move.action_post()
blines.reconcile_payment_lines()
def _prepare_trf_moves(self):
"""

View File

@@ -17,3 +17,6 @@
* Raf Ven <raf.ven@dynapps.be>
* Andrea Stirpe <a.stirpe@onestein.nl>
* `Jarsa <https://www.jarsa.com.mx>`_:
* Alan Ramos <alan.ramos@jarsa.com.mx>

View File

@@ -99,7 +99,7 @@
</td>
<td class="text-center">
<t
t-if="line.move_line_id.move_id and 'in_' in line.move_line_id.move_id.type"
t-if="line.move_line_id.move_id and 'in_' in line.move_line_id.move_id.move_type"
>
<span t-field="line.move_line_id.move_id.ref" />
</t>

View File

@@ -3,12 +3,16 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<!-- QWeb Report -->
<report
id="action_print_payment_order"
model="account.payment.order"
string="Payment Order"
report_type="qweb-pdf"
name="account_payment_order.print_account_payment_order_main"
file="account_payment_order.print_account_payment_order_main"
/>
<record id="action_print_payment_order" model="ir.actions.report">
<field name="name">ayment Order</field>
<field name="model">account.payment.order</field>
<field name="report_type">qweb-pdf</field>
<field
name="report_name"
>account_payment_order.print_account_payment_order_main</field>
<field
name="report_file"
>account_payment_order.print_account_payment_order_main</field>
</record>
</odoo>

View File

@@ -4,3 +4,5 @@ access_account_payment_line,Full access on account.payment.line to Payment Manag
access_bank_payment_line,Full access on bank.payment.line to Payment Manager,model_bank_payment_line,group_account_payment,1,1,1,1
base.access_res_partner_bank_group_partner_manager,Full access on res.partner.bank to Account Payment group,base.model_res_partner_bank,group_account_payment,1,1,1,1
base.access_res_bank_group_partner_manager,Full access on res.bank to Account Payment group,base.model_res_bank,group_account_payment,1,1,1,1
access_account_payment_line_create,access_account_payment_line_create,model_account_payment_line_create,group_account_payment,1,1,1,1
access_account_invoice_payment_line_multi,access_account_invoice_payment_line_multi,model_account_invoice_payment_line_multi,group_account_payment,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
4 access_bank_payment_line Full access on bank.payment.line to Payment Manager model_bank_payment_line group_account_payment 1 1 1 1
5 base.access_res_partner_bank_group_partner_manager Full access on res.partner.bank to Account Payment group base.model_res_partner_bank group_account_payment 1 1 1 1
6 base.access_res_bank_group_partner_manager Full access on res.bank to Account Payment group base.model_res_bank group_account_payment 1 1 1 1
7 access_account_payment_line_create access_account_payment_line_create model_account_payment_line_create group_account_payment 1 1 1 1
8 access_account_invoice_payment_line_multi access_account_invoice_payment_line_multi model_account_invoice_payment_line_multi group_account_payment 1 1 1 1

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-payment/tree/13.0/account_payment_order"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_payment_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-payment/tree/14.0/account_payment_order"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-14-0/bank-payment-14-0-account_payment_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds support for payment orders and debit orders.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -411,7 +411,7 @@ Configuration &gt; Management &gt; Payment Modes.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-payment/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_order%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_order%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -448,6 +448,10 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</li>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li><a class="reference external" href="https://www.jarsa.com.mx">Jarsa</a>:<ul>
<li>Alan Ramos &lt;<a class="reference external" href="mailto:alan.ramos&#64;jarsa.com.mx">alan.ramos&#64;jarsa.com.mx</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
@@ -457,7 +461,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/13.0/account_payment_order">OCA/bank-payment</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/14.0/account_payment_order">OCA/bank-payment</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -66,54 +66,32 @@ class TestAccountPayment(SavepointCase):
{"journal_id": self.bank_journal.id, "payment_type": "inbound", "amount": 1}
)
# check journals
journal_res = new_account_payment._compute_journal_domain_and_types()
journal_domain = journal_res.get("domain")
self.assertTrue(journal_domain)
journals = self.account_journal_model.search(journal_domain)
journals = new_account_payment._get_default_journal()
self.assertIn(self.bank_journal, journals)
# check payment methods
payment_method_res = new_account_payment._onchange_journal()
payment_method_domain = payment_method_res.get("domain", {}).get(
"payment_method_id"
)
self.assertTrue(payment_method_domain)
payment_methods = self.payment_method_model.search(payment_method_domain)
self.assertIn(self.inbound_payment_method_01, payment_methods)
self.assertIn(self.inbound_payment_method_02, payment_methods)
payment_methods = new_account_payment.available_payment_method_ids.ids
self.assertIn(self.inbound_payment_method_01.id, payment_methods)
self.assertIn(self.inbound_payment_method_02.id, payment_methods)
# Set one payment method of the bank journal 'payment order only'
self.inbound_payment_method_01.payment_order_only = True
# check journals
journal_res = new_account_payment._compute_journal_domain_and_types()
journal_domain = journal_res.get("domain")
self.assertTrue(journal_domain)
journals = self.account_journal_model.search(journal_domain)
journals = new_account_payment._get_default_journal()
self.assertIn(self.bank_journal, journals)
# check payment methods
payment_method_res = new_account_payment._onchange_journal()
payment_method_domain = payment_method_res.get("domain", {}).get(
"payment_method_id"
)
self.assertTrue(payment_method_domain)
payment_methods = self.payment_method_model.search(payment_method_domain)
self.assertNotIn(self.inbound_payment_method_01, payment_methods)
self.assertIn(self.inbound_payment_method_02, payment_methods)
new_account_payment._compute_payment_method_fields()
payment_methods = new_account_payment.available_payment_method_ids.ids
self.assertNotIn(self.inbound_payment_method_01.id, payment_methods)
self.assertIn(self.inbound_payment_method_02.id, payment_methods)
# Set all payment methods of the bank journal 'payment order only'
self.inbound_payment_method_02.payment_order_only = True
self.assertTrue(self.inbound_payment_method_01.payment_order_only)
self.assertTrue(self.inbound_payment_method_02.payment_order_only)
self.assertTrue(self.bank_journal.inbound_payment_order_only)
# check journals
journal_res = new_account_payment._compute_journal_domain_and_types()
journal_domain = journal_res.get("domain")
self.assertTrue(journal_domain)
journals = self.account_journal_model.search(journal_domain)
journals = new_account_payment._get_default_journal()
self.assertNotIn(self.bank_journal, journals)
# check payment methods
payment_method_res = new_account_payment._onchange_journal()
payment_method_domain = payment_method_res.get("domain", {}).get(
"payment_method_id"
)
self.assertTrue(payment_method_domain)
payment_methods = self.payment_method_model.search(payment_method_domain)
self.assertNotIn(self.inbound_payment_method_01, payment_methods)
self.assertNotIn(self.inbound_payment_method_02, payment_methods)
new_account_payment._compute_payment_method_fields()
payment_methods = new_account_payment.available_payment_method_ids.ids
self.assertNotIn(self.inbound_payment_method_01.id, payment_methods)
self.assertNotIn(self.inbound_payment_method_02.id, payment_methods)

View File

@@ -88,7 +88,7 @@ class TestPaymentMode(TransactionCase):
self.assertFalse(self.payment_mode_c1.move_option)
def test_onchange_offsetting_account(self):
self.payment_mode_c1.offsetting = "bank_account"
self.payment_mode_c1.offsetting_account = "bank_account"
self.payment_mode_c1.offsetting_account_change()
self.assertFalse(self.payment_mode_c1.transfer_account_id)

View File

@@ -53,7 +53,7 @@ class TestPaymentOrderInboundBase(SavepointCase):
def _create_customer_invoice(self):
with Form(
self.env["account.move"].with_context(default_type="out_invoice")
self.env["account.move"].with_context(default_move_type="out_invoice")
) as invoice_form:
invoice_form.partner_id = self.env.ref("base.res_partner_4")
with invoice_form.invoice_line_ids.new() as invoice_line_form:
@@ -86,8 +86,6 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
bank_journal = self.env["account.journal"].search(
[("type", "=", "bank")], limit=1
)
# Set journal to allow cancelling entries
bank_journal.update_posted = True
payment_order.write({"journal_id": bank_journal.id})

View File

@@ -45,7 +45,7 @@ class TestPaymentOrderOutbound(TransactionCase):
invoice = self.env["account.move"].create(
{
"partner_id": self.env.ref("base.res_partner_4").id,
"type": "in_invoice",
"move_type": "in_invoice",
"payment_mode_id": self.env.ref(
"account_payment_mode.payment_mode_outbound_ct1"
).id,
@@ -155,8 +155,6 @@ class TestPaymentOrderOutbound(TransactionCase):
bank_journal = self.env["account.journal"].search(
[("type", "=", "bank")], limit=1
)
# Set journal to allow cancelling entries
bank_journal.update_posted = True
payment_order.write({"journal_id": bank_journal.id})

View File

@@ -24,7 +24,7 @@
attrs="{'invisible': ['|', '|',
('payment_order_ok', '=', False),
('state', '!=', 'posted'),
('type', 'not in', ('out_invoice', 'out_refund'))
('move_type', 'not in', ('out_invoice', 'out_refund'))
]}"
/>
<button
@@ -35,7 +35,7 @@
attrs="{'invisible': ['|', '|',
('payment_order_ok', '=', False),
('state', '!=', 'posted'),
('type', 'not in', ('in_invoice', 'in_refund'))
('move_type', 'not in', ('in_invoice', 'in_refund'))
]}"
/>
</button>
@@ -48,17 +48,19 @@
required="1"
nolabel="1"
attrs="{'readonly':[('state','!=','draft')],
'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}"
'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"
/>
</field>
</field>
</record>
<act_window
name="Add to Payment/Debit Order"
res_model="account.invoice.payment.line.multi"
binding_model="account.move"
view_mode="form"
target="new"
<record
id="account_invoice_create_account_payment_line_action"
/>
model="ir.actions.act_window"
>
<field name="name">Add to Payment/Debit Order</field>
<field name="res_model">account.invoice.payment.line.multi</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="account.model_account_move" />
</record>
</odoo>

View File

@@ -90,7 +90,7 @@ class AccountPaymentLineCreate(models.TransientModel):
if self.invoice:
domain.append(
(
"move_id.type",
"move_id.move_type",
"in",
("in_invoice", "out_invoice", "in_refund", "out_refund"),
)