Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] account_billing_substate #1686

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 94 additions & 0 deletions account_billing_substate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
===================
Billing - Sub State
===================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:970d0faf9b3b275b6f50e6554fd237a566625a8f3dde24d3093fec1b08f003e9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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
: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
:target: https://github.com/OCA/account-invoicing/tree/16.0/account_billing_substate
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_billing_substate
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to add a substate to journal entry.
For each journal entry state you can define a substate.
We this module you can define substate which allow you to extend accounting workflow.

**Table of contents**

.. contents::
:local:

Usage
=====

#. Go to ** Settings > Technical > Database Structure ** and Add "Base substate".
If necessary you can add "target State values" (ex define a substate for "cancel"
state).
Substate sequence is very important.
#. Create a journal entry and check if the substate are displayed on the header of
form view. Check if you can't set substate defined for journal entry if state is a draft.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
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
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_billing_substate%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Ecosoft

Contributors
~~~~~~~~~~~~

* `Ecosoft <http://ecosoft.co.th>`__:

* Pimolnat Suntian <pimolnats@ecosoft.co.th>

* `360ERP <https://360ERP.com>`__:

* Bosd <bosd>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/16.0/account_billing_substate>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_billing_substate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions account_billing_substate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Ecosoft (<http://ecosoft.co.th>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Billing - Sub State",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"license": "AGPL-3",
"depends": ["account_billing", "base_substate"],
"data": [
"data/account_billing_substate_mail_template_data.xml",
"data/account_billing_substate_data.xml",
"views/account_billing_views.xml",
],
"demo": ["demo/account_billing_substate_demo.xml"],
"installable": True,
}
18 changes: 18 additions & 0 deletions account_billing_substate/data/account_billing_substate_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="base_substate_type_account_billing" model="base.substate.type">
<field name="name">Account Billing Substate</field>
<field name="model">account.billing</field>
<field name="target_state_field">state</field>
</record>
<record id="target_substate_value_billing_draft" model="target.state.value">
<field name="name">Draft</field>
<field name="base_substate_type_id" ref="base_substate_type_account_billing" />
<field name="target_state_value">draft</field>
</record>
<record id="target_substate_value_billing_billed" model="target.state.value">
<field name="name">Billing</field>
<field name="base_substate_type_id" ref="base_substate_type_account_billing" />
<field name="target_state_value">billed</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<!-- Sample account billing substate -related template -->
<record
id="mail_template_data_account_billing_substate_verified"
model="mail.template"
>
<field name="name">Verified</field>
<field name="model_id" ref="account_billing.model_account_billing" />
<field name="subject">Your billing {{object.name}} is verified</field>
<field name="use_default_to" eval="True" />
<field name="body_html" type="html">
<div>
Dear <t t-out="object.user_id.name or 'accounting user'" />,<br />
This email is to inform that your billing <t
t-out="object.name or ''"
/> was verified by accounting manager.
<br /><br />
Best Regards,
<t t-if="user.signature">
<br />
<t t-out="user.signature or ''" />
</t>
</div>
</field>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="auto_delete" eval="True" />
</record>
</odoo>
14 changes: 14 additions & 0 deletions account_billing_substate/demo/account_billing_substate_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<!-- Account Billing Substate -->
<record id="base_substate_to_verify_account_billing" model="base.substate">
<field name="name">To Verify</field>
<field name="sequence">1</field>
<field name="target_state_value_id" ref="target_substate_value_billing_draft" />
</record>
<record id="base_substate_checked_account_billing" model="base.substate">
<field name="name">Checked</field>
<field name="sequence">2</field>
<field name="target_state_value_id" ref="target_substate_value_billing_draft" />
</record>
</odoo>
3 changes: 3 additions & 0 deletions account_billing_substate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_billing
36 changes: 36 additions & 0 deletions account_billing_substate/models/account_billing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2024 Ecosoft (<http://ecosoft.co.th>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class BaseSubstateType(models.Model):
_inherit = "base.substate.type"

model = fields.Selection(
selection_add=[("account.billing", "Account Billing")],
ondelete={"account.billing": "cascade"},
)


class AccountBilling(models.Model):
_inherit = ["account.billing", "base.substate.mixin"]
_name = "account.billing"
_state_field = "state"

def _track_template(self, changes):
res = super()._track_template(changes)
track = self[0]
if "substate_id" in changes and track.substate_id.mail_template_id:
res["substate_id"] = (
track.substate_id.mail_template_id,
{
"composition_mode": "comment",
"auto_delete_message": True,
"subtype_id": self.env["ir.model.data"]._xmlid_to_res_id(
"mail.mt_note"
),
"email_layout_xmlid": "mail.mail_notification_light",
},
)
return res
3 changes: 3 additions & 0 deletions account_billing_substate/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Ecosoft <http://ecosoft.co.th>`__:

* Saran Lim. <saranl@ecosoft.co.th>
3 changes: 3 additions & 0 deletions account_billing_substate/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module allows to add a substate to billing.
For each billing state you can define a substate.
We this module you can define substate which allow you to extend billing workflow.
6 changes: 6 additions & 0 deletions account_billing_substate/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#. Go to ** Settings > Technical > Database Structure ** and Add "Base substate".
If necessary you can add "target State values" (ex define a substate for "cancel"
state).
Substate sequence is very important.
#. Create a billing and check if the substate are displayed on the header of
form view. Check if you can't set substate defined for billing if state is a draft.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.