Skip to content

Commit

Permalink
[MIG] sale_product_set_sale_by_packaging: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed Dec 31, 2024
1 parent 9a971c9 commit 3f32d12
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 68 deletions.
30 changes: 15 additions & 15 deletions product_set_sell_only_by_packaging/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
==================================
Sale Product Set Sale by packaging
==================================
========================================
Sales Product Set Sell only by packaging
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -17,23 +17,22 @@ Sale Product Set Sale by packaging
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/18.0/sale_product_set_sale_by_packaging
:target: https://github.com/OCA/sale-workflow/tree/18.0/product_set_sell_only_by_packaging
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_product_set_sale_by_packaging
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-product_set_sell_only_by_packaging
: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/sale-workflow&target_branch=18.0
:alt: Try me on Runboat

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

Glue module between sale_by_packaging and
sale_product_set_packaging_qty.

If sell_only_by_packaging is ON and there are product set lines without
packaging selected, a warning is displayed in the product form and quick
link to all involved lines allows to review them.
Glue module between sell_only_by_packaging and
sale_product_set_packaging_qty. If sell_only_by_packaging is ON and
there are product set lines without packaging selected, a warning is
displayed in the product form and quick link to all involved lines
allows to review them.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -51,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_product_set_sale_by_packaging%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20product_set_sell_only_by_packaging%0Aversion:%2018.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.

Expand All @@ -71,12 +70,13 @@ Contributors
- `Trobz <https://trobz.com>`__:

- Son Ho<[email protected]>
- Tris Doan<[email protected]>

Other credits
-------------

The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp
The migration of this module from 13.0 to 14.0, and 14.0 to 18.0 was
financially supported by Camptocamp

Maintainers
-----------
Expand All @@ -91,6 +91,6 @@ 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/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_product_set_sale_by_packaging>`_ project on GitHub.
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/product_set_sell_only_by_packaging>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
10 changes: 5 additions & 5 deletions product_set_sell_only_by_packaging/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# @author Simone Orsi <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Sale Product Set Sale by packaging",
"name": "Sales Product Set Sell only by packaging",
"summary": """
Glue module between `sale_by_packaging` and `sale_product_set_packaging_qty`.
Glue module between `sell_only_by_packaging` and `sale_product_set_packaging_qty`.
""",
"version": "14.0.1.0.2",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Warehouse Management",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"auto_install": True,
"depends": ["sale_by_packaging", "sale_product_set_packaging_qty"],
"depends": ["sell_only_by_packaging", "sale_product_set_packaging_qty"],
"data": [
"data/ir_cron.xml",
"views/product_set_line.xml",
Expand Down
1 change: 0 additions & 1 deletion product_set_sell_only_by_packaging/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<field name='name'>Check sale by packaging on wishlist lines</field>
<field name='interval_number'>30</field>
<field name='interval_type'>minutes</field>
<field name="numbercall">-1</field>
<field name="active" eval="True" />
<field name="model_id" ref="sale_product_set.model_product_set_line" />
<field name="state">code</field>
Expand Down
20 changes: 10 additions & 10 deletions product_set_sell_only_by_packaging/models/product_set_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from collections import defaultdict

from odoo import _, api, exceptions, fields, models
from odoo import api, exceptions, fields, models
from odoo.osv import expression

_logger = logging.getLogger(__name__)
Expand All @@ -13,11 +13,10 @@
class ProductSetLine(models.Model):
_inherit = "product.set.line"

# Just for UI purpose
sell_only_by_packaging = fields.Boolean(related="product_id.sell_only_by_packaging")
sell_only_by_packaging = fields.Boolean(
related="product_id.sell_only_by_packaging", readonly=False
)

# The warning is because field "sell_only_by_packaging" is related,
# non-store, non-inherit so not writeable
@api.constrains("sell_only_by_packaging", "product_packaging_id")
def _check_sell_only_by_packaging(self):
errored = self.filtered(
Expand All @@ -29,9 +28,10 @@ def _check_sell_only_by_packaging(self):
)

def _check_sell_only_by_packaging_err_msg(self, lines):
return _(
"The following product(s) can be sold only by packaging: \n %s"
) % ", ".join(lines.mapped("product_id.display_name"))
return self.env._(
"The following product(s) can be sold only by packaging: \n %s",
", ".join(lines.mapped("product_id.display_name")),
)

@api.model
def cron_check_packaging(self):
Expand All @@ -50,7 +50,7 @@ def cron_check_packaging(self):
# or have no packaging
line_domain = expression.OR(
[
[("product_packaging_id.can_be_sold", "=", False)],
[("product_packaging_id.sales", "=", False)],
[
("product_packaging_id", "=", False),
("product_id.sell_only_by_packaging", "=", True),
Expand Down Expand Up @@ -80,5 +80,5 @@ def _fix_lines_packaging(self, line_domain):

def _get_product_first_valid_packaging(self, product):
return fields.first(
product.packaging_ids.filtered(lambda x: x.can_be_sold).sorted("qty")
product.packaging_ids.filtered(lambda x: x.sales).sorted("qty")
)
1 change: 1 addition & 0 deletions product_set_sell_only_by_packaging/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- [Trobz](https://trobz.com):
- Son Ho\<<[email protected]>\>
- Tris Doan\<<[email protected]>\>
2 changes: 1 addition & 1 deletion product_set_sell_only_by_packaging/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
The migration of this module from 13.0 to 14.0 was financially supported
The migration of this module from 13.0 to 14.0, and 14.0 to 18.0 was financially supported
by Camptocamp
4 changes: 1 addition & 3 deletions product_set_sell_only_by_packaging/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Glue module between sale_by_packaging and
sale_product_set_packaging_qty.

Glue module between sell_only_by_packaging and sale_product_set_packaging_qty.
If sell_only_by_packaging is ON and there are product set lines without
packaging selected, a warning is displayed in the product form and quick
link to all involved lines allows to review them.
27 changes: 14 additions & 13 deletions product_set_sell_only_by_packaging/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Sale Product Set Sale by packaging</title>
<title>Sales Product Set Sell only by packaging</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,21 @@
</style>
</head>
<body>
<div class="document" id="sale-product-set-sale-by-packaging">
<h1 class="title">Sale Product Set Sale by packaging</h1>
<div class="document" id="sales-product-set-sell-only-by-packaging">
<h1 class="title">Sales Product Set Sell only by packaging</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:bc76bf83d0a505b5bb676d2d4553aafe771f673bce44e37c8ecb78222f3ee25a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/18.0/sale_product_set_sale_by_packaging"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_product_set_sale_by_packaging"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Glue module between sale_by_packaging and
sale_product_set_packaging_qty.</p>
<p>If sell_only_by_packaging is ON and there are product set lines without
packaging selected, a warning is displayed in the product form and quick
link to all involved lines allows to review them.</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/18.0/product_set_sell_only_by_packaging"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-product_set_sell_only_by_packaging"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Glue module between sell_only_by_packaging and
sale_product_set_packaging_qty. If sell_only_by_packaging is ON and
there are product set lines without packaging selected, a warning is
displayed in the product form and quick link to all involved lines
allows to review them.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -399,7 +399,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_product_set_sale_by_packaging%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20product_set_sell_only_by_packaging%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -416,14 +416,15 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
<li>Son Ho&lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li>
<li>Tris Doan&lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<p>The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp</p>
<p>The migration of this module from 13.0 to 14.0, and 14.0 to 18.0 was
financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
Expand All @@ -434,7 +435,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/18.0/sale_product_set_sale_by_packaging">OCA/sale-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/18.0/product_set_sell_only_by_packaging">OCA/sale-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import exceptions
from odoo.tests import common
from odoo.tests.common import TransactionCase


class TestProductSetPackaging(common.SavepointCase):
class TestProductSetPackaging(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.line = cls.env.ref("sale_product_set.product_set_line_computer_3")
cls.line = cls.env.ref("product_set.product_set_line_computer_3")
cls.packaging = cls.env["product.packaging"].create(
{"name": "Box", "product_id": cls.line.product_id.id, "qty": 10}
)
Expand Down Expand Up @@ -59,10 +59,10 @@ def test_prod_action(self):
)

def test_cron_check_can_be_sold(self):
self.assertTrue(self.packaging.can_be_sold)
self.assertTrue(self.packaging2.can_be_sold)
self.assertTrue(self.packaging.sales)
self.assertTrue(self.packaging2.sales)
self.assertEqual(self.line.product_packaging_id, self.packaging)
self.packaging.can_be_sold = False
self.packaging.sales = False
self.env["product.set.line"].cron_check_packaging()
self.assertEqual(self.line.product_packaging_id, self.packaging2)

Expand Down
18 changes: 7 additions & 11 deletions product_set_sell_only_by_packaging/views/product_set_line.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_product_set_line_tree" model="ir.ui.view">
<field name="name">product.set.line.tree</field>
<field name="name">product.set.line.list</field>
<field name="model">product.set.line</field>
<field name="type">tree</field>
<field name="type">list</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<tree editable="top">
<list editable="top">
<field name="product_set_id" />
<field name="product_id" />
<field name="quantity" />
<field name="discount" groups="product.group_discount_per_so_line" />
<field name="sell_only_by_packaging" invisible="1" />
<field
name="product_packaging_id"
attrs="{'required': [('sell_only_by_packaging', '=', True)]}"
/>
</tree>
<field name="discount" groups="sale.group_discount_per_so_line" />
<field name="product_packaging_id" required="sell_only_by_packaging" />
</list>
</field>
</record>
<record id="view_product_set_line_search" model="ir.ui.view">
Expand Down Expand Up @@ -48,7 +44,7 @@
<field name="name">Product set line</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.set.line</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="view_product_set_line_search" />
<field name="domain">[]</field>
<field name="context">{}</field>
Expand Down
8 changes: 5 additions & 3 deletions product_set_sell_only_by_packaging/views/product_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.view</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="sale_by_packaging.product_template_form_view" />
<field
name="inherit_id"
ref="sell_only_by_packaging.product_template_form_view"
/>
<field name="arch" type="xml">
<label for="sell_only_by_packaging" position="after">
<field name="sell_only_by_packaging_prod_set_tocheck" invisible="1" />
<div
class="alert alert-warning"
role="alert"
attrs="{'invisible': [('sell_only_by_packaging_prod_set_tocheck', '=', False)]}"
invisible="not sell_only_by_packaging_prod_set_tocheck"
>
There are product set lines associated to this product
which do not have a packaging associated.
Expand Down

0 comments on commit 3f32d12

Please sign in to comment.