Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0] [ADD] Payment return block move_lines #313

Open
wants to merge 3 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions account_payment_return/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'views/account_journal_view.xml',
'data/ir_sequence_data.xml',
'views/account_invoice_view.xml',
'views/payment_return_reason.xml',
],
'qweb': [
"static/src/xml/account_payment.xml",
Expand Down
2 changes: 2 additions & 0 deletions account_payment_return/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ class AccountMoveLine(models.Model):
@api.multi
def _payment_returned(self, return_line):
self.mapped('invoice_id')._payment_returned(return_line)
if return_line.reason_id.block_move_lines:
self.write({"blocked": True})
5 changes: 5 additions & 0 deletions account_payment_return/models/payment_return_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class PaymentReturnReason(models.Model):

code = fields.Char()
name = fields.Char(string='Reason', translate=True)
block_move_lines = fields.Boolean(
company_dependent=True,
help="Check 'No Follow-up' on journal items that used to be "
"reconciled with a payment returned with this code.",
)

@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
Expand Down
51 changes: 51 additions & 0 deletions account_payment_return/views/payment_return_reason.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). -->
<odoo>
<record model="ir.ui.view" id="payment_return_reason_form_view">
<field name="model">payment.return.reason</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Payment return reason">
<group>
<field name="code" required="True"/>
<field name="name" required="True"/>
<field name="block_move_lines"/>
</group>
</form>
</field>
</record>

<record model="ir.ui.view" id="payment_return_reason_tree_view">
<field name="model">payment.return.reason</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Payment return reason">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>

<record model="ir.ui.view" id="payment_return_reason_search_view">
<field name="model">payment.return.reason</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search>
<field name="name" filter_domain="['|', ('code', 'ilike', self), ('name', 'ilike', self)]"/>
</search>
</field>
</record>

<record model="ir.actions.act_window" id="payment_return_reason_action">
<field name="name">Payment Return Reasons</field>
<field name="res_model">payment.return.reason</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem id="payment_return_reason_menu"
name="Payment Return Reasons"
parent="account.menu_finance_configuration"
action="payment_return_reason_action"/>
</odoo>