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

[18.0] [MIG] sale_order_customer_free_ref #1126

Merged
merged 16 commits into from
Feb 14, 2025
Merged
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
98 changes: 98 additions & 0 deletions sale_order_customer_free_ref/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
==================================
Sale Order Customer Free Reference
==================================

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

.. |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%2Fedi-lightgray.png?logo=github
:target: https://github.com/OCA/edi/tree/18.0/sale_order_customer_free_ref
:alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-18-0/edi-18-0-sale_order_customer_free_ref
: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/edi&target_branch=18.0
:alt: Try me on Runboat

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

The goal of this module is to improve on the client_order_ref on
sale.order.

By default, Odoo only has one field to handle the customer reference of
a sales order.

However, an order provided by the buyer can contain an id (PO number)
and a free reference. When exchanging with the other parties, you
sometimes need to differentiate them. For instance, this is required by
some EDI flows.

To help with this, this module adds two specific fields for them and
transforms the client_order_ref standard field into a computed one.

The two new fields are also passed on to generated invoices.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/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/edi/issues/new?body=module:%20sale_order_customer_free_ref%0Aversion:%2018.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
------------

- Thierry Ducrest <thierry.ducrest@camptocamp.com>
- `Trobz <https://trobz.com>`__:
- Nguyen Hoang Hiep <hiepnh@trobz.com>

Other credits
-------------

The migration of this module from 13.0 to 14.0 was 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/edi <https://github.com/OCA/edi/tree/18.0/sale_order_customer_free_ref>`_ 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 sale_order_customer_free_ref/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions sale_order_customer_free_ref/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Sale Order Customer Free Reference",
"version": "18.0.1.0.0",
"category": "Sale",
"license": "AGPL-3",
"summary": "Splits the Customer Reference on sale orders into two fields. "
"An Id and a Free reference. The existing field is transformed "
"into a computed one.",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/edi",
"depends": ["sale"],
"data": ["views/sale_order.xml", "views/account_move.xml"],
"installable": True,
}
66 changes: 66 additions & 0 deletions sale_order_customer_free_ref/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_customer_free_ref
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-23 19:23+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\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"
"X-Generator: Weblate 4.17\n"

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_bank_statement_line__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_payment__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__customer_order_free_ref
msgid "Customer Free Reference"
msgstr "Referencia Gratuita al Cliente"

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_bank_statement_line__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_payment__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__customer_order_number
msgid "Customer Order Number"
msgstr "Número de Pedido del Cliente"

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__client_order_ref
msgid "Customer Reference"
msgstr "Referencia del Cliente"

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__display_name
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

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

#. module: sale_order_customer_free_ref
#: model:ir.model,name:sale_order_customer_free_ref.model_account_move
msgid "Journal Entry"
msgstr "Entrada Diaria"

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move____last_update
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. module: sale_order_customer_free_ref
#: model:ir.model,name:sale_order_customer_free_ref.model_sale_order
msgid "Sales Order"
msgstr "Órden de venta"
64 changes: 64 additions & 0 deletions sale_order_customer_free_ref/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_customer_free_ref
#
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: it\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: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_bank_statement_line__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_payment__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__customer_order_free_ref
msgid "Customer Free Reference"
msgstr ""

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_bank_statement_line__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_payment__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__customer_order_number
msgid "Customer Order Number"
msgstr ""

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__client_order_ref
msgid "Customer Reference"
msgstr ""

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

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

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

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

#. module: sale_order_customer_free_ref
#: model:ir.model,name:sale_order_customer_free_ref.model_sale_order
msgid "Sales Order"
msgstr ""
63 changes: 63 additions & 0 deletions sale_order_customer_free_ref/i18n/sale_order_customer_free_ref.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_customer_free_ref
#
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: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_bank_statement_line__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_payment__customer_order_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__customer_order_free_ref
msgid "Customer Free Reference"
msgstr ""

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_bank_statement_line__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_move__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_account_payment__customer_order_number
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__customer_order_number
msgid "Customer Order Number"
msgstr ""

#. module: sale_order_customer_free_ref
#: model:ir.model.fields,field_description:sale_order_customer_free_ref.field_sale_order__client_order_ref
msgid "Customer Reference"
msgstr ""

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

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

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

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

#. module: sale_order_customer_free_ref
#: model:ir.model,name:sale_order_customer_free_ref.model_sale_order
msgid "Sales Order"
msgstr ""
2 changes: 2 additions & 0 deletions sale_order_customer_free_ref/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move
from . import sale_order
11 changes: 11 additions & 0 deletions sale_order_customer_free_ref/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models


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

customer_order_number = fields.Char(copy=False)
customer_order_free_ref = fields.Char(string="Customer Free Reference", copy=False)
46 changes: 46 additions & 0 deletions sale_order_customer_free_ref/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

_client_order_ref_separator = " - "

client_order_ref = fields.Char(
compute="_compute_client_order_ref",
inverse="_inverse_client_order_ref",
string="Customer Reference",
store=True,
copy=False,
)
customer_order_number = fields.Char(copy=False)
customer_order_free_ref = fields.Char(string="Customer Free Reference", copy=False)

@api.depends("customer_order_number", "customer_order_free_ref")
def _compute_client_order_ref(self):
for order in self:
refs = [order.customer_order_number, order.customer_order_free_ref]
refs = [ref for ref in refs if ref and ref.strip()]
order.client_order_ref = self._client_order_ref_separator.join(refs)

def _inverse_client_order_ref(self):
for order in self:
if not order.client_order_ref:
order.customer_order_number = ""
order.customer_order_free_ref = ""
else:
refs = order.client_order_ref.split(self._client_order_ref_separator, 1)
order.customer_order_number = refs[0]
if len(refs) == 2:
order.customer_order_free_ref = refs[1]
else:
order.customer_order_free_ref = ""

def _prepare_invoice(self):
res = super()._prepare_invoice()
res["customer_order_number"] = self.customer_order_number
res["customer_order_free_ref"] = self.customer_order_free_ref
return res
3 changes: 3 additions & 0 deletions sale_order_customer_free_ref/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions sale_order_customer_free_ref/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Thierry Ducrest \<thierry.ducrest@camptocamp.com\>
- [Trobz](https://trobz.com):
- Nguyen Hoang Hiep \<hiepnh@trobz.com\>
2 changes: 2 additions & 0 deletions sale_order_customer_free_ref/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp
Loading