diff --git a/sale_line_partner_variant_description/README.rst b/sale_line_partner_variant_description/README.rst new file mode 100644 index 000000000..fa68382ae --- /dev/null +++ b/sale_line_partner_variant_description/README.rst @@ -0,0 +1,66 @@ +================================================ +Sale line product variant description by partner +================================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a25161d03f3dbe34d3d1ac4dc34007e5afdd2b12e227628f727768c0299b445f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github + :target: https://github.com/NuoBiT/odoo-addons/tree/18.0/sale_line_partner_variant_description + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + +This module replaces the default product description on sale order lines +with the product’s sales description. As a result, no product +description will appear on a sale order line unless the product has a +customer-specific sales description. + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* NuoBiT Solutions SL + +Contributors +------------ + +- `NuoBiT `__: + + - Eric Antones eantones@nuobit.com + - Deniz Gallo dgallo@nuobit.com + +Maintainers +----------- + +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/sale_line_partner_variant_description/__init__.py b/sale_line_partner_variant_description/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/sale_line_partner_variant_description/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_line_partner_variant_description/__manifest__.py b/sale_line_partner_variant_description/__manifest__.py new file mode 100644 index 000000000..ec67501cd --- /dev/null +++ b/sale_line_partner_variant_description/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright NuoBiT Solutions SL - Eric Antones +# Copyright 2026 NuoBit Solutions SL - Deniz Gallo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Sale line product variant description by partner", + "summary": "This module replaces the default product description " + "on sale order lines with the product’s sales description. " + "As a result, no product description will appear on a sale " + "order line unless the product has a customer-specific sales " + "description.", + "version": "18.0.1.0.0", + "category": "Sales", + "author": "NuoBiT Solutions SL", + "website": "https://github.com/NuoBiT/odoo-addons", + "license": "AGPL-3", + "depends": [ + "sale_order_line_variant_description_extension", + "sale_line_partner_description", + ], +} diff --git a/sale_line_partner_variant_description/models/__init__.py b/sale_line_partner_variant_description/models/__init__.py new file mode 100644 index 000000000..5c74c8c30 --- /dev/null +++ b/sale_line_partner_variant_description/models/__init__.py @@ -0,0 +1 @@ +from . import product_product diff --git a/sale_line_partner_variant_description/models/product_product.py b/sale_line_partner_variant_description/models/product_product.py new file mode 100644 index 000000000..c3c227be9 --- /dev/null +++ b/sale_line_partner_variant_description/models/product_product.py @@ -0,0 +1,80 @@ +# Copyright 2025 NuoBiT Solutions SL - Eric Antones +# Copyright 2026 NuoBit Solutions SL - Deniz Gallo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +import re + +from odoo import _, api, models +from odoo.exceptions import ValidationError + + +class ProductProduct(models.Model): + _inherit = "product.product" + + @api.model + def _extract_part(self, part, name): + m = re.match( + rf"^(.*)\n({re.escape(part)})(.*)$", + name, + re.DOTALL, + ) + if m: + desc = m.group(2) + rest = m.group(1) + m.group(3) + else: + raise ValidationError(_("Unexpected format in product name: %s") % name) + return desc, rest + + def get_product_multiline_description_sale(self): + name = super().get_product_multiline_description_sale() + if name: + # extract description parts + m = re.match(r"^(\[[^]]+\]) ([^\n]+)(\n.*)?$", name, re.DOTALL) + if m: + code, desc, rest = m.groups() + else: + m = re.match(r"^([^\n]+)(\n.*)?$", name, re.DOTALL) + if m: + code, desc, rest = (None, *m.groups()) + else: + raise ValidationError( + _("Unexpected format in product name: %s") % name + ) + + # build the new description line + name_l = [] + ref_part_l = [] + if code: + ref_part_l.append(code) + + cand_desc = None + if rest: + if self.variant_description_sale: + cand_desc, rest = self._extract_part( + self.variant_description_sale, rest + ) + else: + if self.description_sale: + cand_desc, rest = self._extract_part( + self.description_sale, rest + ) + + buyer = self._get_buyer_for_partner(self.env.context.get("partner_id")) + if not buyer or not buyer.name: + if cand_desc: + ref_part_l.append(cand_desc) + else: + ref_part_l.append(desc) + else: + ref_part_l.append(desc) + + if ref_part_l: + name_l.append(" ".join(ref_part_l)) + + if rest: + name_l.append(rest) + + if name_l: + name = "".join(name_l) + + return name diff --git a/sale_line_partner_variant_description/pyproject.toml b/sale_line_partner_variant_description/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/sale_line_partner_variant_description/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_line_partner_variant_description/readme/CONTRIBUTORS.md b/sale_line_partner_variant_description/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..909507cba --- /dev/null +++ b/sale_line_partner_variant_description/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [NuoBiT](https://www.nuobit.com): + - Eric Antones + - Deniz Gallo diff --git a/sale_line_partner_variant_description/readme/DESCRIPTION.md b/sale_line_partner_variant_description/readme/DESCRIPTION.md new file mode 100644 index 000000000..0b0b30916 --- /dev/null +++ b/sale_line_partner_variant_description/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module replaces the default product description on sale order lines +with the product’s sales description. As a result, no product +description will appear on a sale order line unless the product has a +customer-specific sales description. diff --git a/sale_line_partner_variant_description/static/description/icon.png b/sale_line_partner_variant_description/static/description/icon.png new file mode 100644 index 000000000..1cd641e79 Binary files /dev/null and b/sale_line_partner_variant_description/static/description/icon.png differ diff --git a/sale_line_partner_variant_description/static/description/index.html b/sale_line_partner_variant_description/static/description/index.html new file mode 100644 index 000000000..50ba28bf5 --- /dev/null +++ b/sale_line_partner_variant_description/static/description/index.html @@ -0,0 +1,423 @@ + + + + + +Sale line product variant description by partner + + + +
+

Sale line product variant description by partner

+ + +

Beta License: AGPL-3 NuoBiT/odoo-addons

+

This module replaces the default product description on sale order lines +with the product’s sales description. As a result, no product +description will appear on a sale order line unless the product has a +customer-specific sales description.

+

Table of contents

+ +
+

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

+
    +
  • NuoBiT Solutions SL
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..ad3089d78 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +odoo-addon-sale_order_line_variant_description_extension@git+https://github.com/nuobit/odoo-addons.git@refs/pull/839/head#subdirectory=sale_order_line_variant_description_extension +odoo-addon-sale_line_partner_description@git+https://github.com/nuobit/odoo-addons.git@refs/pull/738/head#subdirectory=sale_line_partner_description