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

[16.0][MIG] product_nomenclature #522

Merged
merged 21 commits into from
Jan 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
7 changes: 7 additions & 0 deletions product_nomenclature/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

====================
Product Nomenclature
====================
5 changes: 5 additions & 0 deletions product_nomenclature/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2017 Creu Blanca
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import models
20 changes: 20 additions & 0 deletions product_nomenclature/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2017 Creu Blanca
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Product nomenclature",
"version": "16.0.1.0.0",
"author": "CreuBlanca",
"category": "Product",
"depends": ["sale"],
"data": [
"security/ir.model.access.csv",
"views/product_nomenclature_product_views.xml",
"views/product_nomenclature_views.xml",
],
"website": "https://github.com/tegin/cb-addons",
"license": "AGPL-3",
"installable": True,
"auto_install": False,
}
146 changes: 146 additions & 0 deletions product_nomenclature/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_nomenclature
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-14 08:31+0000\n"
"PO-Revision-Date: 2018-11-14 08:31+0000\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_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_active
msgid "Active"
msgstr "Activo"

#. module: product_nomenclature
#: model:ir.ui.view,arch_db:product_nomenclature.product_nomenclature_search
msgid "Archived"
msgstr "Archivado"

#. module: product_nomenclature
#: model:ir.actions.act_window,help:product_nomenclature.product_nomenclature_product_action
msgid "Click to create a nomenclature item."
msgstr "Haga clic para crear un elemento de nomenclatura."

#. module: product_nomenclature
#: model:ir.actions.act_window,help:product_nomenclature.product_nomenclature_action
msgid "Click to create a nomenclature."
msgstr "Haga clic para crear una nomenclatura."

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_code
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_code
msgid "Code"
msgstr "Código"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_create_uid
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_create_uid
msgid "Created by"
msgstr "Creado por"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_create_date
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_create_date
msgid "Created on"
msgstr "Creado en"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_display_name
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_id
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_id
msgid "ID"
msgstr "ID"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_item_ids
msgid "Item"
msgstr "Item"

#. module: product_nomenclature
#: model:ir.ui.view,arch_db:product_nomenclature.product_nomenclature_form
msgid "Items"
msgstr "Elementos"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature___last_update
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product___last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_write_uid
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_write_uid
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_write_date
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_write_date
msgid "Last Updated on"
msgstr "Última actualización el"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_name
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_name
msgid "Name"
msgstr "Nombre"

#. module: product_nomenclature
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_nomenclature_id
#: model:ir.model.fields,field_description:product_nomenclature.field_product_product_nomenclature_ids
msgid "Nomenclature"
msgstr "Nomenclatura"

#. module: product_nomenclature
#: model:ir.actions.act_window,name:product_nomenclature.product_nomenclature_product_action
msgid "Nomenclature Items"
msgstr "Articulos de nomenclatura"

#. module: product_nomenclature
#: model:ir.actions.act_window,name:product_nomenclature.product_nomenclature_action
#: model:ir.ui.view,arch_db:product_nomenclature.product_nomenclature_search
msgid "Nomenclatures"
msgstr "Nomenclaturas"

#. module: product_nomenclature
#: model:ir.model,name:product_nomenclature.model_product_product
#: model:ir.model.fields,field_description:product_nomenclature.field_product_nomenclature_product_product_id
msgid "Product"
msgstr "Producto"

#. module: product_nomenclature
#: model:ir.ui.view,arch_db:product_nomenclature.product_nomenclature_product_search
msgid "Product Nomenclatures"
msgstr "Nomenclaturas de producto"

#. module: product_nomenclature
#: code:addons/product_nomenclature/models/product_nomenclature.py:42
#: sql_constraint:product.nomenclature.product:0
#, python-format
msgid "Product must be unique in a nomenclature"
msgstr "El producto debe ser único en una nomenclatura"

#. module: product_nomenclature
#: model:ir.model,name:product_nomenclature.model_product_nomenclature
msgid "product.nomenclature"
msgstr "product.nomenclature"

#. module: product_nomenclature
#: model:ir.model,name:product_nomenclature.model_product_nomenclature_product
msgid "product.nomenclature.product"
msgstr "product.nomenclatura.producto"

6 changes: 6 additions & 0 deletions product_nomenclature/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2017 Creu Blanca
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import product
from . import product_nomenclature
9 changes: 9 additions & 0 deletions product_nomenclature/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

nomenclature_ids = fields.One2many(
"product.nomenclature.product", inverse_name="product_id"
)
47 changes: 47 additions & 0 deletions product_nomenclature/models/product_nomenclature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from odoo import _, api, fields, models


class ProductNomenclature(models.Model):
_name = "product.nomenclature"
_description = "Product nomenclature"

code = fields.Char(required=True)
name = fields.Text(required=True)
item_ids = fields.One2many(
"product.nomenclature.product", inverse_name="nomenclature_id"
)
active = fields.Boolean(default=True)

def action_view_items(self):
result = self.env["ir.actions.act_window"]._for_xml_id(
"product_nomenclature." "product_nomenclature_product_action"
)
result["context"] = {"default_nomenclature_id": self.id}
result["domain"] = [("nomenclature_id", "=", self.id)]
return result


class ProductNomenclatureProduct(models.Model):
_name = "product.nomenclature.product"
_description = "Product nomenclature product"

nomenclature_id = fields.Many2one("product.nomenclature", required=True)
product_id = fields.Many2one("product.product", required=True)
code = fields.Char(required=True)
name = fields.Char(required=True)
active = fields.Boolean(default=True)

_sql_constraints = [
(
"product_nomenclature_unique",
"unique(product_id, nomenclature_id)",
_("Product must be unique in a nomenclature"),
)
]

@api.onchange("product_id")
def _onchange_product(self):
if not self.name:
self.name = self.product_id.name
if not self.code:
self.code = self.product_id.default_code
5 changes: 5 additions & 0 deletions product_nomenclature/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_nomenclature,access_product_nomenclature,model_product_nomenclature,base.group_user,1,0,0,0
access_product_nomenclature_product,access_product_nomenclature_product,model_product_nomenclature_product,base.group_user,1,0,0,0
salemanager_product_nomenclature,salemanager_product_nomenclature,product_nomenclature.model_product_nomenclature,sales_team.group_sale_manager,1,1,1,1
salemanager_product_nomenclature_product,salemanager_product_nomenclature_product,product_nomenclature.model_product_nomenclature_product,sales_team.group_sale_manager,1,1,1,1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added product_nomenclature/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions product_nomenclature/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_nomenclature
36 changes: 36 additions & 0 deletions product_nomenclature/tests/test_nomenclature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from odoo.tests.common import TransactionCase


class TestNomenclature(TransactionCase):
def setUp(self):
super().setUp()
self.nomenclature = self.env["product.nomenclature"].create(
{"name": "Nomenclature", "code": "nomenclature"}
)
self.product = self.env["product.product"].create(
{"name": "Product", "default_code": "prd"}
)

def test_onchange(self):
item = self.env["product.nomenclature.product"].new(
{
"nomenclature_id": self.nomenclature.id,
"product_id": self.product.id,
}
)
item._onchange_product()
self.assertEqual(self.product.name, item.name)
self.assertEqual(self.product.default_code, item.code)

def test_view(self):
item = self.env["product.nomenclature.product"].create(
{
"nomenclature_id": self.nomenclature.id,
"name": "TESt",
"code": "tests",
"product_id": self.product.id,
}
)
action = self.nomenclature.action_view_items()
items = self.env["product.nomenclature.product"].search(action["domain"])
self.assertIn(item.id, items.ids)
67 changes: 67 additions & 0 deletions product_nomenclature/views/product_nomenclature_product_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="product_nomenclature_product_form" model="ir.ui.view">
<field name="name">product.nomenclature.product.form</field>
<field name="model">product.nomenclature.product</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="nomenclature_id" />
<field name="product_id" options="{'no_create': True}" />
<field name="code" />
<field name="name" />
</group>
</sheet>
</form>
</field>
</record>
<record id="product_nomenclature_product_tree" model="ir.ui.view">
<field name="name">product.nomenclature.product.form</field>
<field name="model">product.nomenclature.product</field>
<field name="priority">10</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="nomenclature_id" invisible="1" />
<field name="product_id" options="{'no_create': True}" />
<field name="code" />
<field name="name" />
<button
name="toggle_active"
type="object"
confirm="Are you sure you want to archive/unarchive this element?"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options='{"terminology": "archive"}'
/>
</button>
</tree>
</field>
</record>
<record id="product_nomenclature_product_search" model="ir.ui.view">
<field name="name">product.nomenclature.product.search</field>
<field name="model">product.nomenclature.product</field>
<field name="arch" type="xml">
<search string="Product Nomenclatures">
<field name="product_id" />
<field name="code" />
<field name="name" />
</search>
</field>
</record>
<record id="product_nomenclature_product_action" model="ir.actions.act_window">
<field name="name">Nomenclature Items</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.nomenclature.product</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a nomenclature item.
</p>
</field>
</record>
</odoo>
Loading
Loading