[IMP] account_partner_reconcile: black, isort, prettier

This commit is contained in:
mreficent
2020-01-29 13:04:41 +01:00
committed by jcoux
parent f4c31c3cee
commit 9278512cbc
8 changed files with 61 additions and 59 deletions

View File

@@ -3,18 +3,13 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
'name': "Account Partner Reconcile", "name": "Account Partner Reconcile",
'version': '12.0.1.0.1', "version": "12.0.1.0.1",
'category': 'Accounting', "category": "Accounting",
'author': 'Eficent,' "author": "Eficent," "Odoo Community Association (OCA), ",
'Odoo Community Association (OCA), ', "website": "https://github.com/OCA/account-reconcile",
'website': 'https://github.com/OCA/account-reconcile', "license": "AGPL-3",
'license': 'AGPL-3', "depends": ["account"],
"depends": [ "data": ["views/res_partner_view.xml"],
'account', "installable": True,
],
"data": [
'views/res_partner_view.xml',
],
"installable": True
} }

View File

@@ -6,22 +6,24 @@ from odoo import api, models
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = "res.partner"
@api.multi @api.multi
def action_open_reconcile(self): def action_open_reconcile(self):
# Open reconciliation view for customers and suppliers # Open reconciliation view for customers and suppliers
reconcile_mode = self.env.context.get('reconcile_mode', False) reconcile_mode = self.env.context.get("reconcile_mode", False)
accounts = self.property_account_payable_id accounts = self.property_account_payable_id
if reconcile_mode == 'customers': if reconcile_mode == "customers":
accounts = self.property_account_receivable_id accounts = self.property_account_receivable_id
action_context = {'show_mode_selector': True, action_context = {
'partner_ids': [self.id, ], "show_mode_selector": True,
'mode': reconcile_mode, "partner_ids": [self.id],
'account_ids': accounts.ids} "mode": reconcile_mode,
return { "account_ids": accounts.ids,
'type': 'ir.actions.client', }
'tag': 'manual_reconciliation_view', return {
'context': action_context, "type": "ir.actions.client",
"tag": "manual_reconciliation_view",
"context": action_context,
} }

View File

@@ -1,2 +1,2 @@
The button is visible only to users that belong to the accounting groups The button is visible only to users that belong to the accounting groups
"Accountant" or "Adviser". "Accountant" or "Adviser".

View File

@@ -1,2 +1,2 @@
* Jordi Ballester <jordi.ballester@eficent.com> * Jordi Ballester <jordi.ballester@eficent.com>
* Jaume Planas <jaume.planas@minorisa.net> * Jaume Planas <jaume.planas@minorisa.net>

View File

@@ -1,2 +1,2 @@
This module adds a button "Match Payments" in the customer & suppliers form This module adds a button "Match Payments" in the customer & suppliers form
view to allow to start the matching of invoices & payments for that partner. view to allow to start the matching of invoices & payments for that partner.

View File

@@ -1,3 +1,3 @@
#. Enable 'Show Full Accounting Features' #. Enable 'Show Full Accounting Features'
#. Create a new Customer Invoice and Payment #. Create a new Customer Invoice and Payment
#. Go to the Customer/Supplier view form and click on Match payments #. Go to the Customer/Supplier view form and click on Match payments

View File

@@ -13,26 +13,24 @@ class TestAccountPartnerReconcile(TransactionCase):
def setUp(self): def setUp(self):
super(TestAccountPartnerReconcile, self).setUp() super(TestAccountPartnerReconcile, self).setUp()
self.partner1 = self.env.ref('base.res_partner_1') self.partner1 = self.env.ref("base.res_partner_1")
def test_account_partner_reconcile(self): def test_account_partner_reconcile(self):
res = self.partner1.action_open_reconcile() res = self.partner1.action_open_reconcile()
# assertDictContainsSubset is deprecated in Python <3.2 # assertDictContainsSubset is deprecated in Python <3.2
expect = { expect = {"type": "ir.actions.client", "tag": "manual_reconciliation_view"}
'type': 'ir.actions.client',
'tag': 'manual_reconciliation_view',
}
self.assertDictEqual( self.assertDictEqual(
expect, {k: v for k, v in res.items() if k in expect}, expect,
'There was an error and the manual_reconciliation_view ' {k: v for k, v in res.items() if k in expect},
'couldn\'t be opened.') "There was an error and the manual_reconciliation_view "
"couldn't be opened.",
)
expect = { expect = {"partner_ids": self.partner1.ids, "show_mode_selector": True}
'partner_ids': self.partner1.ids,
'show_mode_selector': True,
}
self.assertDictEqual( self.assertDictEqual(
expect, {k: v for k, v in res['context'].items() if k in expect}, expect,
'There was an error and the manual_reconciliation_view ' {k: v for k, v in res["context"].items() if k in expect},
'couldn\'t be opened.') "There was an error and the manual_reconciliation_view "
"couldn't be opened.",
)

View File

@@ -1,28 +1,35 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<!--Copyright 2017-19 Eficent Business and IT Consulting Services S.L.--> <!--Copyright 2017-19 Eficent Business and IT Consulting Services S.L.-->
<!--(http://www.eficent.com)--> <!--(http://www.eficent.com)-->
<!--License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).--> <!--License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).-->
<record id="res_partner_view_buttons" model="ir.ui.view"> <record id="res_partner_view_buttons" model="ir.ui.view">
<field name="name">res.partner.view.buttons</field> <field name="name">res.partner.view.buttons</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" /> <field name="inherit_id" ref="base.view_partner_form" />
<field name="priority" eval="20"/> <field name="priority" eval="20" />
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/> <field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<div name="button_box" position="inside"> <div name="button_box" position="inside">
<button class="oe_stat_button" type="object" <button
name="action_open_reconcile" class="oe_stat_button"
context="{'reconcile_mode': 'customers'}" type="object"
icon="fa-usd" string="Match Receivables"> name="action_open_reconcile"
context="{'reconcile_mode': 'customers'}"
icon="fa-usd"
string="Match Receivables"
>
</button> </button>
<button class="oe_stat_button" type="object" <button
name="action_open_reconcile" class="oe_stat_button"
context="{'reconcile_mode': 'suppliers'}" type="object"
icon="fa-usd" string="Match Payables"> name="action_open_reconcile"
context="{'reconcile_mode': 'suppliers'}"
icon="fa-usd"
string="Match Payables"
>
</button> </button>
</div> </div>
</field> </field>
</record> </record>
</odoo> </odoo>