Skip to content

Commit

Permalink
[ADD] account_invoice_bank_brand
Browse files Browse the repository at this point in the history
  • Loading branch information
qgroulard committed May 13, 2024
1 parent 5276559 commit bff93db
Show file tree
Hide file tree
Showing 16 changed files with 684 additions and 0 deletions.
87 changes: 87 additions & 0 deletions account_invoice_bank_brand/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==========================
Account Invoice Bank Brand
==========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fbrand-lightgray.png?logo=github
:target: https://github.com/OCA/brand/tree/12.0/account_invoice_bank_brand
:alt: OCA/brand
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/brand-12-0/brand-12-0-account_invoice_bank_brand
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/284/12.0
:alt: Try me on Runbot

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

This addon allows to set partner_bank_id on invoices depending on the brand.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to Settings > Users & Companies > Brands
#. Select a brand
#. Define bank account
#. Create a new invoice
#. Select the brand
#. Save

The bank account is filled with the brand bank account.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/brand/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/brand/issues/new?body=module:%20account_invoice_bank_brand%0Aversion:%2012.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
~~~~~~~

* ACSONE SA/NV

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

* Quentin Groulard <[email protected]>

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/brand <https://github.com/OCA/brand/tree/12.0/account_invoice_bank_brand>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_invoice_bank_brand/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions account_invoice_bank_brand/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Account Invoice Bank Brand",
"summary": """
This addon allows to set partner_bank_id on invoices depending on the brand.""",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/brand",
"depends": ["account_brand"],
"data": ["views/res_brand.xml"],
}
2 changes: 2 additions & 0 deletions account_invoice_bank_brand/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_invoice
from . import res_brand
27 changes: 27 additions & 0 deletions account_invoice_bank_brand/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from collections import OrderedDict

from odoo import api, models


class AccountInvoice(models.Model):

_inherit = "account.invoice"

def _get_onchange_create(self):
res = super()._get_onchange_create()
return OrderedDict(
[("_onchange_brand", ["partner_bank_id"])] + list(res.items())
)

@api.onchange("brand_id")
def _onchange_brand(self):
invoice_type = self.type or self.env.context.get("type", "out_invoice")
if (
invoice_type in ("out_invoice", "in_refund")
and self.brand_id
and self.brand_id.partner_bank_id
):
self.partner_bank_id = self.brand_id.partner_bank_id
33 changes: 33 additions & 0 deletions account_invoice_bank_brand/models/res_brand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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


class ResBrand(models.Model):

_inherit = "res.brand"

partner_bank_id = fields.Many2one(
comodel_name="res.partner.bank",
domain="[('partner_id.ref_company_ids', 'in', [company_id])]",
string="Bank Account",
description="Company Bank Account Number to which the invoices of this "
"brand will be paid (for Customer Invoice and Vendor Credit Note)",
)

@api.constrains("company_id", "partner_bank_id")
def validate_partner_bank_id(self):
for record in self:
if (
record.partner_bank_id
and not record.company_id
in record.partner_bank_id.partner_id.ref_company_ids
):
raise ValidationError(
_(
"The account selected for invoices payment does not "
"belong to the same company as this brand."
)
)
1 change: 1 addition & 0 deletions account_invoice_bank_brand/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Quentin Groulard <[email protected]>
1 change: 1 addition & 0 deletions account_invoice_bank_brand/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This addon allows to set partner_bank_id on invoices depending on the brand.
10 changes: 10 additions & 0 deletions account_invoice_bank_brand/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To use this module, you need to:

#. Go to Settings > Users & Companies > Brands
#. Select a brand
#. Define bank account
#. Create a new invoice
#. Select the brand
#. Save

The bank account is filled with the brand bank account.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bff93db

Please sign in to comment.