forked from OCA/product-attribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'refs/pull/1237/head' of https://github.com/oca/product-…
…attribute into 16.0-5471
- Loading branch information
Showing
21 changed files
with
837 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
====================== | ||
Product Code Mandatory | ||
====================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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%2Fproduct--attribute-lightgray.png?logo=github | ||
:target: https://github.com/OCA/product-attribute/tree/15.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-15-0/product-attribute-15-0-product_code_mandatory | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/135/15.0 | ||
:alt: Try me on Runbot | ||
|
||
|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. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
: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 smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_code_mandatory%0Aversion:%2015.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> | ||
|
||
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/15.0/product_code_mandatory>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from . import models | ||
|
||
from odoo import api, SUPERUSER_ID | ||
|
||
|
||
def pre_init_product_code(cr): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
|
||
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 cr.fetchall()] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "16.0.1.0.1", | ||
"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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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" | ||
msgstr "Producte" | ||
|
||
#. 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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
# * 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" | ||
msgstr "Article" | ||
|
||
#. 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 "Display Name" | ||
#~ msgstr "Nom affiché" | ||
|
||
#~ msgid "Last Modified on" | ||
#~ msgstr "Dernière modification" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
# * 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" | ||
msgstr "Article" | ||
|
||
#. 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 "Display Name" | ||
#~ msgstr "Nom affiché" | ||
|
||
#~ msgid "Last Modified on" | ||
#~ msgstr "Dernière modification" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# 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" | ||
"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__default_code | ||
msgid "Internal Reference" | ||
msgstr "" | ||
|
||
#. module: product_code_mandatory | ||
#: model:ir.model,name:product_code_mandatory.model_product_product | ||
msgid "Product" | ||
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_code_mandatory | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2020-03-23 14:13+0000\n" | ||
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n" | ||
"Language-Team: none\n" | ||
"Language: pt\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 3.10\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" | ||
msgstr "Produto" | ||
|
||
#. 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 "" | ||
"Defina como '/' e guarde caso pretenda que uma nova referência interna seja " | ||
"proposta." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (C) 2018 - TODAY, Open Source Integrators License AGPL-3.0 | ||
# or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
def _get_default_code(self): | ||
return self.env["ir.sequence"].next_by_code("product.default.code") | ||
|
||
default_code = fields.Char( | ||
"Internal Reference", index=True, default=_get_default_code | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* Antonio Yamuta <ayamuta@opensourceintegrators.com> | ||
* Sudhir Arya <sudhir@erpharbor.com> | ||
* Watthanun Khorchai <watthanun_t@hotmail.com> | ||
* Nedas Žilinskas <nedas.zilinskas@web-veistamo.fi> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This module sets the field internal reference (default_code) of the product | ||
as required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* 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. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/135/12.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.