Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e63f744
[11.0] product_internal_reference_mandatory (#334)
agyamuta Jun 12, 2018
2cef8e9
[MIG] Migrated product_code_mandatory to v12
sudhir-erpharbor Dec 4, 2018
8a32f06
Added translation using Weblate (Portuguese)
pedrocs-exo Mar 23, 2020
e0a1bff
[IMP] product_code_mandatory: black, isort, prettier
Jul 9, 2020
6f7e9b8
[13.0][MIG] product_code_mandatory
Jul 9, 2020
3f42067
[MIG] product_code_mandatory: Migration to 14.0
watthanun Dec 4, 2020
fdc06be
Added translation using Weblate (French)
Yvesldff Apr 10, 2021
bca5654
[MIG] product_code_mandatory: Migration to 15.0
Jan 19, 2022
90802cc
Added translation using Weblate (Catalan)
pablontura Apr 22, 2022
663fc9f
Update translation files
oca-transbot Jul 3, 2022
11b1f91
[FIX] product_code_mandatory: align code with Odoo way to set default…
augusto-weiss Sep 15, 2022
6b154c0
Added translation using Weblate (Italian)
mymage Oct 31, 2023
0b018f5
[IMP] product_code_mandatory: pre-commit stuff
Apr 9, 2024
c63a689
[MIG] poduct_code_mandatory: Migration to 16.0
Apr 9, 2024
9c712db
[IMP] product_code_mandatory: Add review improvements
rov-adhoc Jul 26, 2024
2b2db10
[IMP] product_code_mandatory: pre-commit execution
ced-adhoc Jul 30, 2024
d496575
[MIG] product_code_mandatory: Migration to 17.0
ced-adhoc Jul 30, 2024
0bfb4f0
[UPD] Update product_code_mandatory.pot
Aug 2, 2024
bba73ec
Update translation files
weblate Aug 2, 2024
c1a3beb
Translated using Weblate (Italian)
mymage Aug 4, 2024
fcf24fc
[MIG] product_code_mandatory: Migration to 18.0
pfranck Jan 15, 2025
d6cc49c
[IMP] product_code_mandatory: pre-commit execution
lef-adhoc Nov 5, 2025
e01e685
[MIG] product_code_mandatory: Migration to 19.0
lef-adhoc Nov 5, 2025
6c8ecf6
Merge PR #2125 into 19.0
OCA-git-bot Aug 3, 2026
d3395cc
[UPD] Update product_code_mandatory.pot
Aug 3, 2026
d5c5b09
[BOT] post-merge updates
OCA-git-bot Aug 3, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ addon | version | maintainers | summary
[product_category_type](product_category_type/) | 19.0.1.0.0 | <a href='https://github.com/legalsylvain'><img src='https://github.com/legalsylvain.png' width='32' height='32' style='border-radius:50%;' alt='legalsylvain'/></a> | Add Type field on Product Categories to distinguish between parent and final categories
[product_category_uom](product_category_uom/) | 19.0.1.0.0 | | Define default product UoM at product category level
[product_class](product_class/) | 19.0.1.0.0 | <a href='https://github.com/Ricardoalso'><img src='https://github.com/Ricardoalso.png' width='32' height='32' style='border-radius:50%;' alt='Ricardoalso'/></a> <a href='https://github.com/ivantodorovich'><img src='https://github.com/ivantodorovich.png' width='32' height='32' style='border-radius:50%;' alt='ivantodorovich'/></a> | Product classification and attribute constraints
[product_code_mandatory](product_code_mandatory/) | 19.0.1.0.0 | | Set Product Internal Reference as a required field
[product_code_unique](product_code_unique/) | 19.0.1.0.0 | | Set Product Internal Reference as Unique
[product_company_default](product_company_default/) | 19.0.1.0.0 | | Product Company Default
[product_customerinfo](product_customerinfo/) | 19.0.1.0.0 | <a href='https://github.com/luisg123v'><img src='https://github.com/luisg123v.png' width='32' height='32' style='border-radius:50%;' alt='luisg123v'/></a> | Allows to define prices for customers in the products
Expand Down
102 changes: 102 additions & 0 deletions product_code_mandatory/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================
Product Code Mandatory
======================

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

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

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

This module sets the field internal reference (default_code) of the
product as required.

**Table of contents**

.. contents::
:local:

Usage
=====

- Unable to save a product with an empty or blank internal reference.
- When creating more than one product variant from the template, a
variant will be created with a default value for default_code field.
- A pre_init_hook process is initiated when there exist records without
an internal reference(default_code). A default value is generated to
populate empty field as a temporary value.

|Try me on Runbot|

.. |Try me on Runbot| image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:target: https://runbot.odoo-community.org/runbot/135/12.0

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

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

* Open Source Integrators

Contributors
------------

- Antonio Yamuta <ayamuta@opensourceintegrators.com>
- Sudhir Arya <sudhir@erpharbor.com>
- Watthanun Khorchai <watthanun_t@hotmail.com>
- Nedas Žilinskas <nedas.zilinskas@web-veistamo.fi>
- `Binhex <https://binhex.cloud/>`__:

- Mario Luis Mora <m.luis@binhex.cloud>

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/product-attribute <https://github.com/OCA/product-attribute/tree/19.0/product_code_mandatory>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
23 changes: 23 additions & 0 deletions product_code_mandatory/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from . import models


def pre_init_product_code(env):
env.cr.execute(
"""
SELECT product_tmpl_id from product_product
WHERE default_code is NULL
OR LENGTH(default_code) = 0
GROUP BY product_tmpl_id
HAVING COUNT(product_tmpl_id) = 1"""
)
product_template_ids = [x[0] for x in env.cr.fetchall()]
env.cr.execute(
"""UPDATE product_product
SET default_code = 'DEFAULT' || nextval('ir_default_id_seq')
WHERE default_code is NULL
OR LENGTH(default_code) = 0"""
)

env["product.template"].browse(product_template_ids)._compute_default_code()

return True
16 changes: 16 additions & 0 deletions product_code_mandatory/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product Code Mandatory",
"summary": "Set Product Internal Reference as a required field",
"version": "19.0.1.0.0",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "Product",
"website": "https://github.com/OCA/product-attribute",
"depends": ["product"],
"data": ["data/product_code_seq.xml", "views/product_view.xml"],
"pre_init_hook": "pre_init_product_code",
"installable": True,
}
10 changes: 10 additions & 0 deletions product_code_mandatory/data/product_code_seq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<odoo noupdate="1">
<record id="product_default_code_seq" model="ir.sequence">
<field name="name">Product Default Code Mandatory</field>
<field name="code">product.default.code</field>
<field name="prefix">DEFAULT-</field>
<field name="padding">4</field>
<field name="company_id" eval="False" />
</record>
</odoo>
36 changes: 36 additions & 0 deletions product_code_mandatory/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_mandatory
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-04-22 10:05+0000\n"
"Last-Translator: pablontura <pablo.ruiz@qubiq.es>\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"
"X-Generator: Weblate 4.3.2\n"

#. module: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__default_code
msgid "Internal Reference"
msgstr "Referència interna"

#. module: product_code_mandatory
#: model:ir.model,name:product_code_mandatory.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_code_mandatory
#: model:ir.model.fields,help:product_code_mandatory.field_product_product__default_code
msgid ""
"Set to '/' and save if you want a new internal reference to be proposed."
msgstr ""

#~ msgid "Product"
#~ msgstr "Producte"
44 changes: 44 additions & 0 deletions product_code_mandatory/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_mandatory
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-04-10 11:46+0000\n"
"Last-Translator: Yves Le Doeuff <yld@alliasys.fr>\n"
"Language-Team: none\n"
"Language: fr\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.3.2\n"

#. module: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__default_code
msgid "Internal Reference"
msgstr "Référence interne"

#. module: product_code_mandatory
#: model:ir.model,name:product_code_mandatory.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_code_mandatory
#: model:ir.model.fields,help:product_code_mandatory.field_product_product__default_code
msgid ""
"Set to '/' and save if you want a new internal reference to be proposed."
msgstr ""
"Mettez '/' et sauvegardez si vous voulez qu'une nouvelle référence vous soit "
"proposée."

#~ msgid "Product"
#~ msgstr "Article"

#~ msgid "Display Name"
#~ msgstr "Nom affiché"

#~ msgid "Last Modified on"
#~ msgstr "Dernière modification"
44 changes: 44 additions & 0 deletions product_code_mandatory/i18n/fr_FR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_mandatory
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-04-10 15:46+0000\n"
"Last-Translator: Yves Le Doeuff <yld@alliasys.fr>\n"
"Language-Team: none\n"
"Language: fr_FR\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.3.2\n"

#. module: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__default_code
msgid "Internal Reference"
msgstr "Référence interne"

#. module: product_code_mandatory
#: model:ir.model,name:product_code_mandatory.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_code_mandatory
#: model:ir.model.fields,help:product_code_mandatory.field_product_product__default_code
msgid ""
"Set to '/' and save if you want a new internal reference to be proposed."
msgstr ""
"Mettez '/' et sauvegardez si vous voulez qu'une nouvelle référence vous soit "
"proposée."

#~ msgid "Product"
#~ msgstr "Article"

#~ msgid "Display Name"
#~ msgstr "Nom affiché"

#~ msgid "Last Modified on"
#~ msgstr "Dernière modification"
38 changes: 38 additions & 0 deletions product_code_mandatory/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_mandatory
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-08-04 21:58+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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"
"X-Generator: Weblate 5.6.2\n"

#. module: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__default_code
msgid "Internal Reference"
msgstr "Riferimento interno"

#. module: product_code_mandatory
#: model:ir.model,name:product_code_mandatory.model_product_product
msgid "Product Variant"
msgstr "Variante prodotto"

#. module: product_code_mandatory
#: model:ir.model.fields,help:product_code_mandatory.field_product_product__default_code
msgid ""
"Set to '/' and save if you want a new internal reference to be proposed."
msgstr ""
"Impostare a '/' e salvare se si vuole venga proposto un nuovo riferimento "
"interno."

#~ msgid "Product"
#~ msgstr "Prodotto"
34 changes: 34 additions & 0 deletions product_code_mandatory/i18n/product_code_mandatory.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_code_mandatory
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.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: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__display_name
msgid "Display Name"
msgstr ""

#. module: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__id
msgid "ID"
msgstr ""

#. module: product_code_mandatory
#: model:ir.model.fields,field_description:product_code_mandatory.field_product_product__default_code
msgid "Internal Reference"
msgstr ""

#. module: product_code_mandatory
#: model:ir.model,name:product_code_mandatory.model_product_product
msgid "Product Variant"
msgstr ""
Loading