Skip to content

Commit

Permalink
IMP eurofactor: add filters/group
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Oct 31, 2024
1 parent 6742a65 commit 5d38b06
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 2 deletions.
1 change: 1 addition & 0 deletions account_factoring_receivable_balance/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"views/subrogation_receipt.xml",
"views/partner.xml",
"views/account_move.xml",
"views/account_move_line.xml",
"data/action.xml",
],
"demo": [],
Expand Down
54 changes: 54 additions & 0 deletions account_factoring_receivable_balance/views/account_move_line.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_move_line_tree" model="ir.ui.view">
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree" />
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='account_id']" position="before">
<field name="subrogation_id" string="Subrogation" optional="hide" />
</xpath>
</field>
</record>

<record id="view_account_move_line_filter" model="ir.ui.view">
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_account_move_line_filter" />
<field name="arch" type="xml">
<filter name="posted" position="after">
<separator />
<filter
name="subrogation_id"
string="Subrogation"
domain="[('subrogation_id', '!=', False)]"
/>
</filter>
<xpath expr="//group" position="inside">
<filter
string="Subrogation"
name="group_by_subrogation_id"
domain="[]"
context="{'group_by': 'subrogation_id'}"
/>
</xpath>
</field>
</record>


<!-- TO FIX
<record id="action_account_move_line_subrogation" model="ir.actions.act_window">
<field name="context">{'subrogation_id', '!=', False}</field>
<field name="name">Ecritures avec Subrogations</field>
<field name="res_model">account.move.line</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="account.view_move_line_tree_grouped_sales_purchases"/>
</record>
<menuitem
id="account_moves_subrogation_menu"
parent="factoring_menu"
sequence="10"
action="action_account_move_line_subrogation"
/>
-->
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"data": [
"views/partner.xml",
"views/account_journal.xml",
"views/account_move_line.xml",
"views/subrogation.xml",
"data/data.xml",
"report/subrogation.xml",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2024 David BEAL @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models
from odoo import fields, models


class AccountMove(models.Model):
Expand All @@ -19,6 +19,8 @@ def _display_eurofactor_bank(self):
class AccountMoveLine(models.Model):
_inherit = "account.move.line"

eurofactor_ref = fields.Char(related="partner_id.eurofactor_ref", string="Eurof")

def _eurof_fields_rpt(self):
partner = self.partner_id.commercial_partner_id
ref = partner._get_partner_eurof_mapping().get(partner, "")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2024 David BEAL @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import api, fields, models

MODULE = __name__[12 : __name__.index(".", 13)]

Expand All @@ -14,6 +14,7 @@ class ResPartner(models.Model):
company_dependent=True,
groups="account.group_account_manager",
)
eurofactor_ref = fields.Char()

def _get_partner_eurof_mapping(self):
rec_categ = self.env.ref(f"{MODULE}.eurofactor_id_category")
Expand Down Expand Up @@ -42,3 +43,27 @@ def printit(records):
"n'ont pas de compte bancaire d'identifiant d'affacturage."
)
return message


class ResPartnerId_number(models.Model):
_inherit = "res.partner.id_number"

dummy = fields.Boolean(compute="_compute_dummy", store=True)

@api.depends("partner_id", "category_id", "name")
def _compute_dummy(self):
for rec in self:
if (
rec.partner_id
and rec.env.ref(f"{MODULE}.eurofactor_id_category") == rec.category_id
):
rec.partner_id.eurofactor_ref = rec.name
else:
rec.partner_id.eurofactor_ref = False

def unlink(self):
res = super().unlink()
for rec in self:
if rec.partner_id:
rec.partner_id.eurofactor_ref = False
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_move_line_tree" model="ir.ui.view">
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree" />
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='partner_id']" position="before">
<field name="eurofactor_ref" string="Eurofactor" optional="hide" />
</xpath>
</field>
</record>

<record id="view_account_move_line_filter" model="ir.ui.view">
<field name="model">account.move.line</field>
<field
name="inherit_id"
ref="account_factoring_receivable_balance.view_account_move_line_filter"
/>
<field name="arch" type="xml">
<filter name="subrogation_id" position="after">
<filter
name="eurofactor_ref"
string="Eurofactor"
domain="[('eurofactor_ref', '!=', False)]"
/>
</filter>
</field>
</record>


</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
string="Eurofactor Id"
name="id_numbers"
domain="[('id_numbers', '!=', False)]"
/>
<filter
string="Eurofactor OK"
name="eurofactor_ok"
domain="[('eurofactor_ref', '!=', False), ('factor_bank_id','!=', 0)]"
/>
<separator />
</xpath>
Expand Down

0 comments on commit 5d38b06

Please sign in to comment.