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

[15.0][MIG] account_move_original_partner: Migration to 15.0 #1496

Open
wants to merge 8 commits into
base: 15.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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions account_move_original_partner/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
===============================
Acccount Move Original Partners
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/14.0/account_move_original_partner
: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-14-0/account-invoicing-14-0-account_move_original_partner
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/95/14.0
:alt: Try me on Runbot

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

When invoicing multiple sale orders at the same time, they may be grouped into
a single invoice. When it happens, it is hard to retrieve who the original SO
partners were.

This module helps by retrieving such partners and showing them into the invoice
form view, alongside the invoice partner itself.

**Table of contents**

.. contents::
:local:

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_move_original_partner%0Aversion:%2014.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
~~~~~~~

* Camptocamp

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

* `Camptocamp <https://www.camptocamp.com>`_

* Silvio Gregorini <[email protected]>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

* Camptocamp

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/14.0/account_move_original_partner>`_ project on GitHub.

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

from . import models

from .hooks import post_init_hook
17 changes: 17 additions & 0 deletions account_move_original_partner/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Acccount Move Original Partners",
"version": "15.0.1.0.0",
"summary": "Display original customers when creating invoices from"
" multiple sale orders.",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"license": "AGPL-3",
"category": "Accounting & Finance",
"depends": ["account", "sale"],
"data": ["views/account_move.xml"],
"installable": True,
"post_init_hook": "post_init_hook",
}
27 changes: 27 additions & 0 deletions account_move_original_partner/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from logging import getLogger

from odoo import SUPERUSER_ID, api

_logger = getLogger(__name__)


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
force_compute_original_partners(env)


def force_compute_original_partners(env):
"""Force compute original partners.
Since field `original_partner_ids` is not automatically computed upon
module installation, we need to compute it manually on existing records.
:param env: an Odoo Environment instance
"""
domain = [("move_type", "=", "out_invoice")]
invs = env["account.move"].search(domain)
_logger.info("Force-compute original partners on %s invoices" % len(invs))
invs._compute_original_partner_ids()
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_original_partner
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move__display_name
msgid "Display Name"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move__id
msgid "ID"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model,name:account_move_original_partner.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_bank_statement_line__original_partner_ids
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move__original_partner_ids
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_payment__original_partner_ids
msgid "Original Partners"
msgstr ""
42 changes: 42 additions & 0 deletions account_move_original_partner/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_original_partner
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move__display_name
msgid "Display Name"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move__id
msgid "ID"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model,name:account_move_original_partner.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_move_original_partner
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_bank_statement_line__original_partner_ids
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_move__original_partner_ids
#: model:ir.model.fields,field_description:account_move_original_partner.field_account_payment__original_partner_ids
msgid "Original Partners"
msgstr ""
1 change: 1 addition & 0 deletions account_move_original_partner/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move
26 changes: 26 additions & 0 deletions account_move_original_partner/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models


class AccountMove(models.Model):
_inherit = "account.move"

original_partner_ids = fields.Many2many(
comodel_name="res.partner",
relation="account_move_original_partner_rel",
column1="account_move_id",
column2="res_partner_id",
compute="_compute_original_partner_ids",
store=True,
string="Original Partners",
)

@api.depends("move_type", "invoice_line_ids.sale_line_ids.order_id.partner_id")
def _compute_original_partner_ids(self):
for move in self:
move.original_partner_ids = (
move.move_type == "out_invoice"
and move.invoice_line_ids.mapped("sale_line_ids.order_id.partner_id")
)
3 changes: 3 additions & 0 deletions account_move_original_partner/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Camptocamp <https://www.camptocamp.com>`_

* Silvio Gregorini <[email protected]>
3 changes: 3 additions & 0 deletions account_move_original_partner/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

* Camptocamp
6 changes: 6 additions & 0 deletions account_move_original_partner/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
When invoicing multiple sale orders at the same time, they may be grouped into
a single invoice. When it happens, it is hard to retrieve who the original SO
partners were.

This module helps by retrieving such partners and showing them into the invoice
form view, alongside the invoice partner itself.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading