Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
03112c9
[DEV-456][IMP] account_billing: reflect OCA changes
AungKoKoLin1997 May 22, 2026
5492557
[DEV-456][IMP] account_move_order_partner: reflect OCA changes
AungKoKoLin1997 May 22, 2026
050f532
[DEV-456][IMP] auditlog: reflect OCA changes
AungKoKoLin1997 May 22, 2026
d1e73b8
[DEV-456][IMP] base_user_role: reflect OCA changes
AungKoKoLin1997 May 22, 2026
7720ebc
[DEV-456][IMP] l10n_jp_country_state: reflect OCA changes
AungKoKoLin1997 May 22, 2026
9cb9fdc
[DEV-456][IMP] l10n_jp_summary_invoice: reflect OCA changes
AungKoKoLin1997 May 22, 2026
befc166
[DEV-456][IMP] mail_layout_force: reflect OCA changes
AungKoKoLin1997 May 22, 2026
74a2295
[DEV-456][IMP] partner_bank_acc_holder_name: reflect OCA changes
AungKoKoLin1997 May 22, 2026
933ef88
[DEV-456][IMP] partner_contact_address_default: reflect OCA changes
AungKoKoLin1997 May 22, 2026
40763c1
[DEV-456][IMP] purchase_order_etd_eta: reflect OCA changes
AungKoKoLin1997 May 22, 2026
9c22fa6
[DEV-456][IMP] purchase_order_secondary_unit: reflect OCA changes
AungKoKoLin1997 May 22, 2026
ffad14b
[DEV-456][IMP] report_pdf_zip_download: reflect OCA changes
AungKoKoLin1997 May 22, 2026
2ba436a
[DEV-456][IMP] report_positioned_image: reflect OCA changes
AungKoKoLin1997 May 22, 2026
2408950
[DEV-456][IMP] report_qweb_field_option: reflect OCA changes
AungKoKoLin1997 May 22, 2026
4ee3c47
[DEV-456][IMP] sale_commercial_partner: reflect OCA changes
AungKoKoLin1997 May 22, 2026
e9f8cc8
[DEV-456][IMP] sale_line_name_option: reflect OCA changes
AungKoKoLin1997 May 22, 2026
df68049
[DEV-456][IMP] sale_partner_shipping_default_partner_invoice: reflect…
AungKoKoLin1997 May 22, 2026
e97f4e2
[DEV-456][IMP] sale_pricelist_from_commitment_date: reflect OCA changes
AungKoKoLin1997 May 22, 2026
6cc64fc
[DEV-456][IMP] sale_stock_partner_warehouse: reflect OCA changes
AungKoKoLin1997 May 22, 2026
eea22a5
[DEV-456][IMP] stock_move_actual_date: reflect OCA changes
AungKoKoLin1997 May 22, 2026
e1a670a
[DEV-456][IMP] stock_secondary_unit: reflect OCA changes
AungKoKoLin1997 May 22, 2026
9f4558f
[DEV-456][IMP] template_content_swapper: reflect OCA changes
AungKoKoLin1997 May 22, 2026
462c07a
[DEV-456][IMP] web_favicon: reflect OCA changes
AungKoKoLin1997 May 22, 2026
c686636
[DEV-456][IMP] web_form_banner: reflect OCA changes
AungKoKoLin1997 May 22, 2026
42722a6
[DEV-456][IMP] web_m2x_options: reflect OCA changes
AungKoKoLin1997 May 22, 2026
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
16 changes: 10 additions & 6 deletions account_billing/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============
Billing Process
===============
Expand All @@ -7,13 +11,13 @@ Billing Process
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:92c644c45d119de640798ae4ef9b43eb634e6b78de5811a1ac6c5f3d647499f0
!! source digest: sha256:50d733e0ce5080841df88469b4939fc61943ac75ba37cb787877b142628c7554
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
Expand Down Expand Up @@ -79,10 +83,10 @@ Authors
Contributors
------------

- Kitti U. <kittiu@ecosoft.co.th>
- Saran Lim. <saranl@ecosoft.co.th>
- Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
- Komsan Somwong <komsan.s@ecosoft.co.th>
- Kitti U. <kittiu@ecosoft.co.th>
- Saran Lim. <saranl@ecosoft.co.th>
- Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
- Komsan Somwong <komsan.s@ecosoft.co.th>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion account_billing/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Billing Process",
"summary": "Group invoice as billing before payment",
"version": "18.0.1.1.1",
"version": "18.0.1.3.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/account-invoicing",
Expand Down
94 changes: 56 additions & 38 deletions account_billing/models/account_billing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright 2019 Ecosoft Co., Ltd (https://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from datetime import date

from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError

Expand Down Expand Up @@ -93,18 +91,34 @@ class AccountBilling(models.Model):
selection=[("invoice_date_due", "Due Date"), ("invoice_date", "Invoice Date")],
required=True,
readonly=True,
default=lambda self: self._get_default_threshold_date_type(),
default="invoice_date_due",
help="All invoices with date (threshold date type) before and equal to "
"threshold date will be listed in billing lines",
)
payment_paid_all = fields.Boolean(
compute="_compute_payment_paid_all",
store=True,
)

@api.model
def _get_default_threshold_date_type(self):
return "invoice_date_due"
amount_untaxed = fields.Monetary(
string="Untaxed Amount",
compute="_compute_tax_totals",
store=True,
)
amount_tax = fields.Monetary(
string="Tax Amount",
compute="_compute_tax_totals",
store=True,
)
amount_total = fields.Monetary(
string="Total Amount",
compute="_compute_tax_totals",
store=True,
)
amount_total_residual = fields.Monetary(
string="Total Amount Residual",
compute="_compute_amount_total_residual",
store=True,
)

@api.depends("billing_line_ids.payment_state")
def _compute_payment_paid_all(self):
Expand All @@ -116,35 +130,47 @@ def _compute_payment_paid_all(self):
line.payment_state == "paid" for line in rec.billing_line_ids
)

def _get_moves_domain(self, date, types=False):
return [
("partner_id", "=", self.partner_id.id),
("state", "=", "posted"),
("payment_state", "!=", "paid"),
("currency_id", "=", self.currency_id.id),
(date, "<=", self.threshold_date),
("move_type", "in", types),
]

def _get_moves(self, date, types=False):
moves = self.env["account.move"].search(
[
("partner_id", "=", self.partner_id.id),
("state", "=", "posted"),
("payment_state", "!=", "paid"),
("currency_id", "=", self.currency_id.id),
(date, "<=", self.threshold_date),
("move_type", "in", types),
]
)
return moves._sort_for_billing(self.threshold_date_type)
domain = self._get_moves_domain(date, types=types)
return self.env["account.move"].search(domain)

def _compute_invoice_related_count(self):
self.invoice_related_count = len(self.billing_line_ids)

@api.onchange("threshold_date_type")
def _onchange_threshold_date_type(self):
self._sort_billing_lines()
@api.depends("billing_line_ids.amount_residual")
def _compute_amount_total_residual(self):
for rec in self:
rec.amount_total_residual = sum(
rec.billing_line_ids.mapped("amount_residual")
)

def _sort_billing_lines(self):
if not self.billing_line_ids:
return
sorted_lines = self.billing_line_ids.sorted(
key=lambda x: (x.invoice_date or date.min, x.name or "", x.id)
)
for idx, line in enumerate(sorted_lines, start=1):
line.sequence = idx * 10
self.invalidate_recordset(["billing_line_ids"])
@api.depends(
"billing_line_ids.move_id.amount_untaxed", "billing_line_ids.move_id.amount_tax"
)
def _compute_tax_totals(self):
for bill in self:
bill.amount_untaxed = 0.0
bill.amount_tax = 0.0
bill.amount_total = 0.0

for line in bill.billing_line_ids:
sign = (
-1 if line.move_id.move_type in ["out_refund", "in_refund"] else 1
)
bill.amount_untaxed += line.move_id.amount_untaxed * sign
bill.amount_tax += line.move_id.amount_tax * sign

bill.amount_total = bill.amount_untaxed + bill.amount_tax

def name_get(self):
result = [(billing.id, (billing.name or "Draft")) for billing in self]
Expand Down Expand Up @@ -234,15 +260,12 @@ def compute_lines(self):
moves = self._get_moves(self.threshold_date_type, types)
billing_line_dict = self._get_billing_line_dict(moves)
self.billing_line_ids.create(billing_line_dict)
self._sort_billing_lines()


class AccountBillingLine(models.Model):
_name = "account.billing.line"
_description = "Billing Line"
_order = "sequence, id"

sequence = fields.Integer(default=10)
billing_id = fields.Many2one(comodel_name="account.billing")
move_id = fields.Many2one(
comodel_name="account.move",
Expand All @@ -264,11 +287,6 @@ class AccountBillingLine(models.Model):
state = fields.Selection(related="move_id.state")
payment_state = fields.Selection(related="move_id.payment_state")

@api.depends(
"billing_id.threshold_date_type",
"move_id.invoice_date",
"move_id.invoice_date_due",
)
def _compute_invoice_date(self):
for line in self:
if line.billing_id.threshold_date_type == "invoice_date_due":
Expand Down
18 changes: 9 additions & 9 deletions account_billing/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@
class AccountMove(models.Model):
_inherit = "account.move"

billing_line_ids = fields.One2many(
comodel_name="account.billing.line",
inverse_name="move_id",
string="Billing Lines",
help="Billing lines that reference this invoice",
)
billing_ids = fields.Many2many(
comodel_name="account.billing",
string="Billings",
compute="_compute_billing_ids",
groups="account.group_account_invoice",
help="Relationship between invoice and billing",
)

def _compute_billing_ids(self):
bl_obj = self.env["account.billing.line"]
for rec in self:
billing_lines = bl_obj.search([("move_id", "=", rec.id)])
rec.billing_ids = billing_lines.mapped("billing_id")
rec.billing_ids = rec.billing_line_ids.mapped("billing_id")

def _get_billing_type(self):
outbound_types = {"out_invoice", "out_refund", "out_receipt"}
move_types = set(self.mapped("move_type"))
return "out_invoice" if move_types.issubset(outbound_types) else "in_invoice"

def _sort_for_billing(self, date_field):
return self.sorted(key=lambda m: (m[date_field], m.name, m.id))

def _create_billing(self, partner):
date_field = self.env["account.billing"]._get_default_threshold_date_type()
billing = self.env["account.billing"].create(
{
"partner_id": partner.id,
Expand All @@ -46,11 +47,10 @@ def _create_billing(self, partner):
* (-1 if m.move_type in ["out_refund", "in_refund"] else 1),
}
)
for m in self._sort_for_billing(date_field)
for m in self
],
}
)
billing._sort_billing_lines()
return billing

def action_create_billing(self):
Expand Down
28 changes: 17 additions & 11 deletions account_billing/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Billing Process</title>
<title>README.rst</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,16 +360,21 @@
</style>
</head>
<body>
<div class="document" id="billing-process">
<h1 class="title">Billing Process</h1>
<div class="document">


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="billing-process">
<h1>Billing Process</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:92c644c45d119de640798ae4ef9b43eb634e6b78de5811a1ac6c5f3d647499f0
!! source digest: sha256:50d733e0ce5080841df88469b4939fc61943ac75ba37cb787877b142628c7554
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoicing/tree/18.0/account_billing"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-account_billing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoicing/tree/18.0/account_billing"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-account_billing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>In some countries, there is a customary practice for companies to
collect money from their customers only once in a month. For example,
the customer has 3 payments due in a given month, the vendor or billing
Expand All @@ -393,7 +398,7 @@ <h1 class="title">Billing Process</h1>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<p>To use this module, you have 2 ways:</p>
<ol class="arabic">
<li><div class="first line-block">
Expand All @@ -411,23 +416,23 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoicing/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_billing%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<ul class="simple">
<li>Ecosoft</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<ul class="simple">
<li>Kitti U. &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
Expand All @@ -436,7 +441,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -451,5 +456,6 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
</div>
</div>
</div>
</div>
</body>
</html>
Loading
Loading