diff --git a/__manifest__.py b/__manifest__.py index 06892d89ec0e5af4ca51d76b6aa42a3c3e55303c..e1705a62b9c4ab885b7f32dbf4d1aa4a0ed00176 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -20,6 +20,7 @@ "views/account_invoice.xml", "views/account_payment_term.xml", "views/account_payment_order.xml", + "views/account_payment_line.xml", "views/res_config_settings.xml", "views/res_partner.xml", "views/scop_cotisation_task.xml", diff --git a/models/account_payment_order.py b/models/account_payment_order.py index 7b8b4013da03a85f046c21e2aaaa295d7e3bf381..dd14b130c44ed6e136ae88d1deaf35473699a9ac 100644 --- a/models/account_payment_order.py +++ b/models/account_payment_order.py @@ -7,11 +7,36 @@ from odoo import fields, models, api class ModelName(models.Model): _inherit = 'account.payment.order' + payment_line_amount = fields.Float( + string='Total Transactions', + compute='_compute_payment_line_amount' + ) + bank_line_amount = fields.Float( + string='Total Lignes de paiement', + compute='_compute_bank_line_amount' + ) attachment_ids = fields.One2many( comodel_name='ir.attachment', compute='_compute_attachment_ids' ) + # ------------------------------------------------------ + # Compute fields + # ------------------------------------------------------ + @api.multi + def _compute_payment_line_amount(self): + for po in self: + po.payment_line_amount = sum( + po.payment_line_ids.mapped('amount_currency') + ) + + @api.multi + def _compute_bank_line_amount(self): + for po in self: + po.bank_line_amount = sum( + po.bank_line_ids.mapped('amount_currency') + ) + @api.multi def _compute_attachment_ids(self): Attachment = self.env['ir.attachment'] @@ -20,3 +45,20 @@ class ModelName(models.Model): ('res_model', '=', 'account.payment.order'), ('res_id', '=', po.id) ]) + + # ------------------------------------------------------ + # Button function + # ------------------------------------------------------ + def view_payment_line(self): + tree_id = self.env.ref( + 'cgscop_cotisation.scop_account_payment_line_tree').id + search_id = self.env.ref( + 'cgscop_cotisation.scop_account_payment_line_search').id + return { + 'type': 'ir.actions.act_window', + 'name': 'Lignes dde transaction', + 'res_model': 'account.payment.line', + 'views': [[tree_id, 'tree']], + 'search_view_id': [search_id, 'search'], + 'domain': [['order_id', '=', self.id]], + } \ No newline at end of file diff --git a/views/account_payment_line.xml b/views/account_payment_line.xml new file mode 100644 index 0000000000000000000000000000000000000000..814d4671edd7c4c74f9414db0ccc34f4eaa10b1f --- /dev/null +++ b/views/account_payment_line.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <!-- Copyright 2020 Le Filament + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + <data> + <!-- Tree View --> + <record id="scop_account_payment_line_tree" model="ir.ui.view"> + <field name="name">scop.account.payment.line.tree</field> + <field name="model">account.payment.line</field> + <field name="arch" type="xml"> + <tree string="Payment Lines" editable="top" create="0"> + <field name="partner_id"/> + <field name="communication"/> + <field name="partner_bank_id"/> + <field name="mandate_id"/> + <field name="move_line_id" invisible="1"/> + <field name="ml_maturity_date"/> + <field name="date"/> + <field name="amount_currency" string="Montant"/> + <field name="name"/> + <field name="amount_company_currency" sum="Total in Company Currency" invisible="1"/> + <field name="payment_type" invisible="1"/> + </tree> + </field> + </record> + + <!-- Search View --> + <record id="scop_account_payment_line_search" model="ir.ui.view"> + <field name="name">scop.account.payment.line.search</field> + <field name="model">account.payment.line</field> + <field name="arch" type="xml"> + <search string="Lignes de paiement"> + <field name="partner_id" string="Adhérent"/> + <field name="communication" string="N° Facture"/> + <field name="mandate_id" string="Mandat de prélèvement"/> + <field name="partner_bank_id" string="Compte bancaire"/> + </search> + </field> + </record> + + </data> +</odoo> \ No newline at end of file diff --git a/views/account_payment_order.xml b/views/account_payment_order.xml index c04eb59d34b6d6aaaefeacd01f2cbaad23b35cfb..775a9fef1551dbff84839e4708c59bd85958ad6e 100644 --- a/views/account_payment_order.xml +++ b/views/account_payment_order.xml @@ -9,6 +9,14 @@ <field name="model">account.payment.order</field> <field name="inherit_id" ref="account_payment_order.account_payment_order_form"/> <field name="arch" type="xml"> + <xpath expr="//field[@name='bank_line_count']" position="after"> + <field name="payment_line_amount"/> + <field name="bank_line_amount"/> + <button name="view_payment_line" + type="object" + string="Modifier les lignes de paiement" + attrs="{'invisible': [('state', '!=', 'draft')]}"/> + </xpath> <xpath expr="//notebook" position="inside"> <page name="attachments" string="Fichiers de prélèvements"> <field name="attachment_ids">