Skip to content

Commit

Permalink
add remit-to bank field
Browse files Browse the repository at this point in the history
  • Loading branch information
yostashiro committed Jan 29, 2025
1 parent 527f72a commit 73a69b9
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 19 deletions.
4 changes: 2 additions & 2 deletions l10n_jp_summary_invoice/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 Quartile (https://www.quartile.co)
# Copyright 2024-2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "JP Summary Invoice",
Expand All @@ -7,7 +7,7 @@
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-japan",
"license": "AGPL-3",
"depends": ["account_billing"],
"depends": ["account_billing", "report_alternative_layout"],
"data": [
"reports/report.xml",
"reports/report_summary_invoice.xml",
Expand Down
1 change: 1 addition & 0 deletions l10n_jp_summary_invoice/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import account_billing
from . import ir_actions_report
12 changes: 11 additions & 1 deletion l10n_jp_summary_invoice/models/account_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ class AccountBilling(models.Model):
"account.journal",
help="This journal will be used for tax adjustment journal entry.",
)
company_partner_id = fields.Many2one(related="company_id.partner_id", store=True)
remit_to_bank_id = fields.Many2one(
"res.partner.bank",
"Remit-to Bank",
domain="[('partner_id', '=', company_partner_id)]",
help="If not specified, the first bank account linked to the company will show "
"in the report.",
)

@api.depends("billing_line_ids")
def _compute_billing_date_due(self):
for billing in self:
if not billing.billing_line_ids:
continue
billing.date_due = max(
move.invoice_date_due for move in self.billing_line_ids.move_id
move.invoice_date_due for move in billing.billing_line_ids.move_id
)

@api.depends("billing_line_ids.move_id")
Expand Down
18 changes: 18 additions & 0 deletions l10n_jp_summary_invoice/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class Report(models.Model):
_inherit = "ir.actions.report"

def _get_remit_to_bank(self, record):
res = super()._get_remit_to_bank(record)
if (
not res
or not record._name == "account.billing"
or not record.remit_to_bank_id
):
return res
return record.remit_to_bank_id
9 changes: 8 additions & 1 deletion l10n_jp_summary_invoice/reports/report.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<odoo>
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="report_jp_summary_invoice" model="ir.actions.report">
<field name="name">JP Summary Invoice</field>
<field name="model">account.billing</field>
Expand All @@ -10,5 +11,11 @@
<field
name="print_report_name"
>'Summary Invoice-%s%s' % (object.name, object.state == 'draft' and '-draft' or '')</field>
<field
name="paperformat_id"
ref="report_alternative_layout.report_paperformat_a4_alt"
/>
<field name="apply_alternative_layout" eval="True" />
<field name="show_remit_to_bank" eval="True" />
</record>
</odoo>
4 changes: 0 additions & 4 deletions l10n_jp_summary_invoice/reports/report_summary_invoice.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<odoo>
<template id="report_summary_invoice_document">
<t t-call="web.external_layout">
<div
t-field="o.partner_id.commercial_partner_id"
t-options='{"widget": "contact", "fields": ["phone"]}'
/>
<div class="mt-5">
<div class="page">
<h2>
Expand Down
32 changes: 21 additions & 11 deletions l10n_jp_summary_invoice/views/account_billing_views.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_account_billing_form_inherit" model="ir.ui.view">
<field name="name">account.billing.form.inherit</field>
<field name="model">account.billing</field>
<field name="inherit_id" ref="account_billing.view_account_billing_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='date']" position="after">
<xpath expr="//field[@name='payment_paid_all']" position="after">
<field name="company_partner_id" invisible="1" />
<field
name="date_due"
attrs="{'invisible': [('bill_type', '!=', 'out_invoice')]}"
name="remit_to_bank_id"
attrs="{'invisible':[('bill_type','!=','out_invoice')]}"
/>
</xpath>
<xpath expr="//field[@name='currency_id']" position="after">
<field
name="tax_entry_journal_id"
attrs="{'invisible': [('bill_type', '!=', 'out_invoice')]}"
/>
<xpath expr="//field[@name='date']" position="after">
<field
name="tax_adjustment_entry_id"
readonly="1"
attrs="{'invisible': [('bill_type', '!=', 'out_invoice')]}"
name="date_due"
attrs="{'invisible':[('bill_type','!=','out_invoice')]}"
/>
</xpath>
<xpath expr="//notebook" position="inside">
<page
string="Tax Adjustment"
attrs="{'invisible':[('bill_type','!=','out_invoice')]}"
>
<group>
<group>
<field name="tax_entry_journal_id" />
<field name="tax_adjustment_entry_id" readonly="1" />
</group>
</group>
</page>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 73a69b9

Please sign in to comment.