diff --git a/product_origin/README.md b/product_origin/README.md deleted file mode 100644 index ecdbcd5..0000000 --- a/product_origin/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Product Origin - -## Summary - -Adds an origin field to products to track where they come from (geographic origin). - -## Features - -- **Origin Field**: Adds a text field to store the product's origin -- **Visible in Views**: Shows in both product template and product variant forms -- **Simple Implementation**: Extends core product models - -## Technical Details - -### Models Extended - -- `product.template`: Main product template -- `product.product`: Product variants - -### Fields Added - -- `origin` (Char): Text field for product origin - -### Views Modified - -- Product Template Form -- Product Variant Form - -## Dependencies - -- `product` (Odoo core) - -## Installation - -```bash -docker-compose exec odoo odoo -d odoo -u product_origin --stop-after-init -``` - -## Usage - -1. Open a product form (Products > Products > [Product]) -2. Find the "Origin" field -3. Enter the geographic origin (e.g., "Spain", "France", "Local") - -## OCA Source - -- **Repository**: [product-attribute](https://github.com/OCA/product-attribute) -- **Original Authors**: ACSONE SA/NV, GRAP -- **License**: AGPL-3 - -## Modifications for Kidekoop - -None - Used as-is from OCA. - -## Translations - -- ✅ Spanish (es) -- ✅ Euskera (eu) - -Located in `i18n/` directory. - ---- - -**Version**: 18.0.1.0.0 -**License**: AGPL-3 diff --git a/product_origin/README.rst b/product_origin/README.rst deleted file mode 100644 index 9ff9d21..0000000 --- a/product_origin/README.rst +++ /dev/null @@ -1,114 +0,0 @@ -============== -Product Origin -============== - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:2db486ad6cf453e31192b518e0e0de9647f6b65545047439e05da8bc413dc410 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |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/18.0/product_origin - :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-18-0/product-attribute-18-0-product_origin - :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=18.0 - :alt: Try me on Runboat - -|badge1| |badge2| |badge3| |badge4| |badge5| - -This module adds a field to associate the country and state of origin of -a product - -https://en.wikipedia.org/wiki/Country_of_origin - -**Table of contents** - -.. contents:: - :local: - -Usage -===== - -- Go to product form -- Fill in the country and/or state of origin of the product under the - 'General Information' tab. - -|image1| - -.. |image1| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_origin/static/description/product_form.png - -Changelog -========= - -10.0.1.0.0 (2019-01-11) ------------------------ - -- [10.0][ADD] product_origin - -Bug Tracker -=========== - -Bugs are tracked on `GitHub 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 `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -------- - -* ACSONE SA/NV -* GRAP - -Contributors ------------- - -- Denis Roussel -- Sylvain LE GAL (https://twitter.com/legalsylvain) -- `Heliconia Solutions Pvt. Ltd. `__ - - - Bhavesh Heliconia - -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. - -.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px - :target: https://github.com/rousseldenis - :alt: rousseldenis -.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px - :target: https://github.com/legalsylvain - :alt: legalsylvain - -Current `maintainers `__: - -|maintainer-rousseldenis| |maintainer-legalsylvain| - -This module is part of the `OCA/product-attribute `_ project on GitHub. - -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_origin/__init__.py b/product_origin/__init__.py deleted file mode 100644 index 0650744..0000000 --- a/product_origin/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models diff --git a/product_origin/__manifest__.py b/product_origin/__manifest__.py deleted file mode 100644 index 9fd0db1..0000000 --- a/product_origin/__manifest__.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2018 ACSONE SA/NV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -{ - "name": "Product Origin", - "summary": """Adds the origin of the product""", - "version": "18.0.1.0.0", - "license": "AGPL-3", - "development_status": "Beta", - "author": "ACSONE SA/NV,GRAP,Odoo Community Association (OCA)", - "website": "https://github.com/OCA/product-attribute", - "maintainers": ["rousseldenis", "legalsylvain"], - "depends": ["product"], - "data": [ - "views/product_product.xml", - "views/product_template.xml", - ], -} diff --git a/product_origin/i18n/fr.po b/product_origin/i18n/fr.po deleted file mode 100644 index ba493ef..0000000 --- a/product_origin/i18n/fr.po +++ /dev/null @@ -1,72 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * product_origin -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-11 13:46+0000\n" -"PO-Revision-Date: 2024-01-11 13:46+0000\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__state_id -#: model:ir.model.fields,field_description:product_origin.field_product_template__state_id -msgid "Country State of Origin" -msgstr "Région de fabrication" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__country_id -#: model:ir.model.fields,field_description:product_origin.field_product_template__country_id -#: model_terms:ir.ui.view,arch_db:product_origin.product_template_search_view -msgid "Country of Origin" -msgstr "Pays de fabrication" - -#. module: product_origin -#: model_terms:ir.ui.view,arch_db:product_origin.product_template_form_view -#: model_terms:ir.ui.view,arch_db:product_origin.view_product_product_form -#: model_terms:ir.ui.view,arch_db:product_origin.view_product_product_form_variant -msgid "Origin" -msgstr "Origine" - -#. module: product_origin -#: model:ir.model,name:product_origin.model_product_template -msgid "Product" -msgstr "Produit" - -#. module: product_origin -#: model:ir.model,name:product_origin.model_product_product -msgid "Product Variant" -msgstr "Variante de produit" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__state_id_domain -#: model:ir.model.fields,field_description:product_origin.field_product_template__state_id_domain -msgid "State Id Domain" -msgstr "" - -#. module: product_origin -#: model:ir.model.fields,help:product_origin.field_product_product__state_id_domain -#: model:ir.model.fields,help:product_origin.field_product_template__state_id_domain -msgid "" -"Technical field, used to compute dynamically state domain depending on the " -"country." -msgstr "" -"Champ technique, utilisé pour calculer dynamiquement le domaine de l'état, " -"en fonction du pays." - -#. module: product_origin -#. odoo-python -#: code:addons/product_origin/models/product_product.py:0 -#: code:addons/product_origin/models/product_template.py:0 -#, python-format -msgid "" -"The state '%(state_name)s' doesn't belong to the country '%(country_name)s'" -msgstr "La région '%(state_name)s' n'appartient pas au pays '%(country_name)s'" diff --git a/product_origin/i18n/it.po b/product_origin/i18n/it.po deleted file mode 100644 index 1b8e89d..0000000 --- a/product_origin/i18n/it.po +++ /dev/null @@ -1,73 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * product_origin -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2024-05-22 17:37+0000\n" -"Last-Translator: mymage \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 4.17\n" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__state_id -#: model:ir.model.fields,field_description:product_origin.field_product_template__state_id -msgid "Country State of Origin" -msgstr "Nazione paese di orgine" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__country_id -#: model:ir.model.fields,field_description:product_origin.field_product_template__country_id -#: model_terms:ir.ui.view,arch_db:product_origin.product_template_search_view -msgid "Country of Origin" -msgstr "Paese di origine" - -#. module: product_origin -#: model_terms:ir.ui.view,arch_db:product_origin.product_template_form_view -#: model_terms:ir.ui.view,arch_db:product_origin.view_product_product_form -#: model_terms:ir.ui.view,arch_db:product_origin.view_product_product_form_variant -msgid "Origin" -msgstr "Origine" - -#. module: product_origin -#: model:ir.model,name:product_origin.model_product_template -msgid "Product" -msgstr "Prodotto" - -#. module: product_origin -#: model:ir.model,name:product_origin.model_product_product -msgid "Product Variant" -msgstr "Variante prodotto" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__state_id_domain -#: model:ir.model.fields,field_description:product_origin.field_product_template__state_id_domain -msgid "State Id Domain" -msgstr "Dominio ID stato" - -#. module: product_origin -#: model:ir.model.fields,help:product_origin.field_product_product__state_id_domain -#: model:ir.model.fields,help:product_origin.field_product_template__state_id_domain -msgid "" -"Technical field, used to compute dynamically state domain depending on the " -"country." -msgstr "" -"Campo tecnico, utilizzato per calcolare dinamicamente il dominio dello stato " -"in funzione della nazione." - -#. module: product_origin -#. odoo-python -#: code:addons/product_origin/models/product_product.py:0 -#: code:addons/product_origin/models/product_template.py:0 -#, python-format -msgid "" -"The state '%(state_name)s' doesn't belong to the country '%(country_name)s'" -msgstr "" -"Lo stato '%(state_name)s' non appartiene alla nazione '%(country_name)s'" diff --git a/product_origin/i18n/product_origin.pot b/product_origin/i18n/product_origin.pot deleted file mode 100644 index 762c9d6..0000000 --- a/product_origin/i18n/product_origin.pot +++ /dev/null @@ -1,66 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * product_origin -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 18.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_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__state_id -#: model:ir.model.fields,field_description:product_origin.field_product_template__state_id -msgid "Country State of Origin" -msgstr "" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__country_id -#: model:ir.model.fields,field_description:product_origin.field_product_template__country_id -#: model_terms:ir.ui.view,arch_db:product_origin.product_template_search_view -msgid "Country of Origin" -msgstr "" - -#. module: product_origin -#: model_terms:ir.ui.view,arch_db:product_origin.product_template_form_view -#: model_terms:ir.ui.view,arch_db:product_origin.view_product_product_form -#: model_terms:ir.ui.view,arch_db:product_origin.view_product_product_form_variant -msgid "Origin" -msgstr "" - -#. module: product_origin -#: model:ir.model,name:product_origin.model_product_template -msgid "Product" -msgstr "" - -#. module: product_origin -#: model:ir.model,name:product_origin.model_product_product -msgid "Product Variant" -msgstr "" - -#. module: product_origin -#: model:ir.model.fields,field_description:product_origin.field_product_product__state_id_domain -#: model:ir.model.fields,field_description:product_origin.field_product_template__state_id_domain -msgid "State Id Domain" -msgstr "" - -#. module: product_origin -#: model:ir.model.fields,help:product_origin.field_product_product__state_id_domain -#: model:ir.model.fields,help:product_origin.field_product_template__state_id_domain -msgid "" -"Technical field, used to compute dynamically state domain depending on the " -"country." -msgstr "" - -#. module: product_origin -#. odoo-python -#: code:addons/product_origin/models/product_product.py:0 -#: code:addons/product_origin/models/product_template.py:0 -msgid "" -"The state '%(state_name)s' doesn't belong to the country '%(country_name)s'" -msgstr "" diff --git a/product_origin/models/__init__.py b/product_origin/models/__init__.py deleted file mode 100644 index 18b37e8..0000000 --- a/product_origin/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import product_product -from . import product_template diff --git a/product_origin/models/product_product.py b/product_origin/models/product_product.py deleted file mode 100644 index a3271d8..0000000 --- a/product_origin/models/product_product.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import api -from odoo import fields -from odoo import models -from odoo.exceptions import ValidationError - - -class ProductProduct(models.Model): - _inherit = "product.product" - - country_id = fields.Many2one( - comodel_name="res.country", - string="Country of Origin", - ondelete="restrict", - ) - - state_id = fields.Many2one( - comodel_name="res.country.state", - string="Country State of Origin", - ondelete="restrict", - ) - - state_id_domain = fields.Binary( - compute="_compute_state_id_domain", - help="Technical field, used to compute dynamically state domain" - " depending on the country.", - ) - - @api.constrains("country_id", "state_id") - def _check_country_id_state_id(self): - for product in self.filtered(lambda x: x.state_id and x.country_id): - if product.country_id != product.state_id.country_id: - raise ValidationError( - self.env._( - "The state '%(state_name)s' doesn't belong to" - " the country '%(country_name)s'", - state_name=product.state_id.name, - country_name=product.country_id.name, - ) - ) - - @api.onchange("country_id") - def onchange_country_id(self): - if self.state_id and self.state_id.country_id != self.country_id: - self.state_id = False - - @api.onchange("state_id") - def onchange_state_id(self): - if self.state_id: - self.country_id = self.state_id.country_id - - @api.depends("country_id") - def _compute_state_id_domain(self): - for product in self.filtered(lambda x: x.country_id): - product.state_id_domain = [("country_id", "=", product.country_id.id)] - for product in self.filtered(lambda x: not x.country_id): - product.state_id_domain = [] diff --git a/product_origin/models/product_template.py b/product_origin/models/product_template.py deleted file mode 100644 index d524a79..0000000 --- a/product_origin/models/product_template.py +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2018 ACSONE SA/NV -# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api -from odoo import fields -from odoo import models -from odoo.exceptions import ValidationError - - -class ProductTemplate(models.Model): - _inherit = "product.template" - - country_id = fields.Many2one( - comodel_name="res.country", - compute="_compute_country_id", - inverse="_inverse_country_id", - string="Country of Origin", - store=True, - ) - - state_id = fields.Many2one( - comodel_name="res.country.state", - compute="_compute_state_id", - inverse="_inverse_state_id", - string="Country State of Origin", - store=True, - ) - - state_id_domain = fields.Binary( - compute="_compute_state_id_domain", - help="Technical field, used to compute dynamically state domain" - " depending on the country.", - ) - - @api.onchange("country_id") - def onchange_country_id(self): - if self.state_id and self.state_id.country_id != self.country_id: - self.state_id = False - - @api.onchange("state_id") - def onchange_state_id(self): - if self.state_id: - self.country_id = self.state_id.country_id - - @api.constrains("country_id", "state_id") - def _check_country_id_state_id(self): - for template in self.filtered(lambda x: x.state_id and x.country_id): - if template.country_id != template.state_id.country_id: - raise ValidationError( - self.env._( - "The state '%(state_name)s' doesn't belong to" - " the country '%(country_name)s'", - state_name=template.state_id.name, - country_name=template.country_id.name, - ) - ) - - @api.depends("product_variant_ids", "product_variant_ids.country_id") - def _compute_country_id(self): - for template in self: - if template.product_variant_count == 1: - template.country_id = template.product_variant_ids.country_id - else: - template.country_id = False - - def _inverse_country_id(self): - for template in self: - if len(template.product_variant_ids) == 1: - template.product_variant_ids.country_id = template.country_id - - @api.depends("product_variant_ids", "product_variant_ids.state_id") - def _compute_state_id(self): - for template in self: - if template.product_variant_count == 1: - template.state_id = template.product_variant_ids.state_id - else: - template.state_id = False - - @api.depends("country_id") - def _compute_state_id_domain(self): - for template in self.filtered(lambda x: x.country_id): - template.state_id_domain = [("country_id", "=", template.country_id.id)] - for template in self.filtered(lambda x: not x.country_id): - template.state_id_domain = [] - - def _inverse_state_id(self): - for template in self: - if len(template.product_variant_ids) == 1: - template.product_variant_ids.country_id = template.country_id - - def _get_related_fields_variant_template(self): - res = super()._get_related_fields_variant_template() - res += ["country_id", "state_id"] - return res diff --git a/product_origin/pyproject.toml b/product_origin/pyproject.toml deleted file mode 100644 index 4231d0c..0000000 --- a/product_origin/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["whool"] -build-backend = "whool.buildapi" diff --git a/product_origin/readme/CONTRIBUTORS.md b/product_origin/readme/CONTRIBUTORS.md deleted file mode 100644 index 341e1cb..0000000 --- a/product_origin/readme/CONTRIBUTORS.md +++ /dev/null @@ -1,4 +0,0 @@ -- Denis Roussel \<\> -- Sylvain LE GAL () -- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) - - Bhavesh Heliconia diff --git a/product_origin/readme/DESCRIPTION.md b/product_origin/readme/DESCRIPTION.md deleted file mode 100644 index 99e128c..0000000 --- a/product_origin/readme/DESCRIPTION.md +++ /dev/null @@ -1,4 +0,0 @@ -This module adds a field to associate the country and state of origin of -a product - - diff --git a/product_origin/readme/HISTORY.md b/product_origin/readme/HISTORY.md deleted file mode 100644 index a72018d..0000000 --- a/product_origin/readme/HISTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -## 10.0.1.0.0 (2019-01-11) - -- \[10.0\]\[ADD\] product_origin diff --git a/product_origin/readme/USAGE.md b/product_origin/readme/USAGE.md deleted file mode 100644 index 2b62946..0000000 --- a/product_origin/readme/USAGE.md +++ /dev/null @@ -1,5 +0,0 @@ -- Go to product form -- Fill in the country and/or state of origin of the product under the - 'General Information' tab. - -![](../static/description/product_form.png) diff --git a/product_origin/static/description/icon.png b/product_origin/static/description/icon.png deleted file mode 100644 index 3a0328b..0000000 Binary files a/product_origin/static/description/icon.png and /dev/null differ diff --git a/product_origin/static/description/index.html b/product_origin/static/description/index.html deleted file mode 100644 index 69feda9..0000000 --- a/product_origin/static/description/index.html +++ /dev/null @@ -1,456 +0,0 @@ - - - - - -Product Origin - - - -
-

Product Origin

- - -

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

-

This module adds a field to associate the country and state of origin of -a product

-

https://en.wikipedia.org/wiki/Country_of_origin

-

Table of contents

- -
-

Usage

-
    -
  • Go to product form
  • -
  • Fill in the country and/or state of origin of the product under the -‘General Information’ tab.
  • -
-

image1

-
-
-

Changelog

-
-

10.0.1.0.0 (2019-01-11)

-
    -
  • [10.0][ADD] product_origin
  • -
-
-
-
-

Bug Tracker

-

Bugs are tracked on GitHub 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.

-

Do not contact contributors directly about support or help with technical issues.

-
-
-

Credits

-
-

Authors

-
    -
  • ACSONE SA/NV
  • -
  • GRAP
  • -
-
-
-

Contributors

- -
-
-

Maintainers

-

This module is maintained by the OCA.

- -Odoo Community Association - -

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.

-

Current maintainers:

-

rousseldenis legalsylvain

-

This module is part of the OCA/product-attribute project on GitHub.

-

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

-
-
-
- - diff --git a/product_origin/static/description/product_form.png b/product_origin/static/description/product_form.png deleted file mode 100644 index deb4ec6..0000000 Binary files a/product_origin/static/description/product_form.png and /dev/null differ diff --git a/product_origin/tests/__init__.py b/product_origin/tests/__init__.py deleted file mode 100644 index d9b96c4..0000000 --- a/product_origin/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_module diff --git a/product_origin/tests/test_module.py b/product_origin/tests/test_module.py deleted file mode 100644 index 5c01b32..0000000 --- a/product_origin/tests/test_module.py +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo.exceptions import ValidationError - -from odoo.addons.base.tests.common import BaseCommon - - -class TestModule(BaseCommon): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.country_us = cls.env.ref("base.us") - cls.state_tarapaca = cls.env.ref("base.state_cl_01") - cls.state_us = cls.env.ref("base.state_us_1") - cls.country_chile = cls.env.ref("base.cl") - - def test_product_product(self): - self._test_compute_and_constrains(self.env["product.product"]) - self._test_onchange_methods(self.env["product.product"]) - - def test_product_template(self): - self._test_compute_and_constrains(self.env["product.template"]) - self._test_onchange_methods(self.env["product.template"]) - - def _test_compute_and_constrains(self, model): - # Set state should set country - product = model.create({"name": "Test Name"}) - self.assertEqual(product.state_id_domain, []) - - product.country_id = self.country_us - self.assertEqual( - product.state_id_domain, [("country_id", "=", self.country_us.id)] - ) - - with self.assertRaises(ValidationError): - product.state_id = self.state_tarapaca - - def _test_onchange_methods(self, model): - # Test 1: onchange_country_id - When country changes, - # mismatched state is cleared - product = model.create({"name": "Test Onchange"}) - - # Set state first - product.state_id = self.state_us - # Set matching country - product.country_id = self.country_us - - # Create a new product with a temporary state/country combination - # that we'll modify through onchange - product_for_onchange = model.new( - { - "name": "Test Onchange Product", - "state_id": self.state_us.id, - "country_id": self.country_us.id, - } - ) - - # Verify initial state - self.assertEqual(product_for_onchange.state_id.id, self.state_us.id) - self.assertEqual(product_for_onchange.country_id.id, self.country_us.id) - - # Change country and trigger onchange - product_for_onchange.country_id = self.country_chile - product_for_onchange.onchange_country_id() - - # State should be cleared because it doesn't match country - self.assertFalse(product_for_onchange.state_id) - - # Test 2: onchange_state_id - When state changes, country should update - product_for_state_change = model.new( - { - "name": "Test Onchange State", - } - ) - - # Initially no country - self.assertFalse(product_for_state_change.country_id) - - # Set state and trigger onchange - product_for_state_change.state_id = self.state_us - product_for_state_change.onchange_state_id() - - # Country should be set to match state's country - self.assertEqual(product_for_state_change.country_id.id, self.country_us.id) diff --git a/product_origin/views/product_product.xml b/product_origin/views/product_product.xml deleted file mode 100644 index ff148f1..0000000 --- a/product_origin/views/product_product.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - product.product - - - - - - - - - - - - - - product.product - - - - - - - - - - - - diff --git a/product_origin/views/product_template.xml b/product_origin/views/product_template.xml deleted file mode 100644 index 7c55300..0000000 --- a/product_origin/views/product_template.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - product.template - - - - - - - - - - - - - - product.template - - - - - - - - - - -