Skip to content

Commit

Permalink
[MIG] product_sold_by_delivery_week: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cesar-tecnativa committed Jul 14, 2022
1 parent e36744f commit 53fd708
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 19 deletions.
1 change: 1 addition & 0 deletions product_sold_by_delivery_week/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from .hooks import post_init_hook
from . import tests
2 changes: 1 addition & 1 deletion product_sold_by_delivery_week/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Product weekly sales hint",
"summary": "Adds a field that graphically hints the weekly product sales",
"version": "13.0.1.1.1",
"version": "15.0.1.0.0",
"development_status": "Beta",
"category": "Sale",
"website": "https://github.com/OCA/sale-reporting",
Expand Down
2 changes: 1 addition & 1 deletion product_sold_by_delivery_week/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _action_done(self, cancel_backorder=False):
lambda x: x.sale_line_id and x.picking_code == "outgoing"
)
.mapped("product_id")
.with_context(force_company=self.company_id.id)
.with_company(self.company_id)
)
for product in products.filtered(
lambda x: x.weekly_sold_delivered and x.weekly_sold_delivered[-1:] == "0"
Expand Down
10 changes: 5 additions & 5 deletions product_sold_by_delivery_week/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
We can configure some variables with config parameter keys:
Some variables can be configured using config parameter keys:

- For the hint characters:
- For hint characters:

- For the sold char: `product_sold_by_delivery_week.sold_char`
- For the not sold: `product_sold_by_delivery_week.not_sold_char`
- For weeks length: `product_sold_by_delivery_week.weeks_to_consider`
- For weeks length: `product_sold_by_delivery_week.weeks_to_consider`

Assign the security group 'Weekly selling info in order lines' and/or
'Weekly selling info in product list' to users that should see weekly
selling info in order lines or product list. (Is is not necessary if
you want view the info in other views as product recommendation)
sales info in product lists or in order lines. (If you want to see the
info in other views like product recommendations, this is not needed.)
2 changes: 2 additions & 0 deletions product_sold_by_delivery_week/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

* David Vidal
* Carlos Dauden
* César A. Sánchez
* Luis D. Lafaurie
4 changes: 2 additions & 2 deletions product_sold_by_delivery_week/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This module allows to compute a graphical hint stored in the product itself to display
whether or not that product was sold and delivered in the past weeks.
This module allows to compute a graphical hint, stored in the product itself,
to display whether that product was sold and delivered in recent weeks.

.. image:: ../static/description/sold_by_week_hint.png
11 changes: 6 additions & 5 deletions product_sold_by_delivery_week/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* Services aren't taken into consideration.
* A widget could be done on top of the main field to have nicer icons or even colors.
* For the future, maybe a configurable granularity could be made, so we could
change the behaviour to months, days, years as the period of choice. To simplify
the module, for the moment only the week will be considered.
* Services are not taken into consideration.
* A widget could be created on top of the main field to have nicer icons and
probably colors.
* For the near future, a configurable granularity would be desirable, so
behaviour could be changed to years, months or days as the period of choice.
To simplify this module, only weekly periods will be considered for now.
11 changes: 6 additions & 5 deletions product_sold_by_delivery_week/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Once configured, you can view the hints as an optional column in sale order lines or
in the tree of the products.
Once configured, hints will apperar as an optional column in sale order
lines or in products tree.

In the general products view, the general sales info is shown while in the sale lines
field we can see the field in context filtering only the partner sales.
In the general products view, general sales info is shown. Meanwhile, in the
sale lines field we can see this field in context by simply filtering partner
sales.

Only salesmen can access to this information.
Only salespeople can access this information.
1 change: 1 addition & 0 deletions product_sold_by_delivery_week/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_product_sold_by_delivery_week
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo.tests import TransactionCase


class TestProductSoldByDeliveryWeek(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

cls.partner = cls.env.ref("base.res_partner_12")
cls.product = cls.env.ref("product.product_product_9")
cls.product_expense_product = cls.env.ref("product.expense_product")
cls.product.weekly_sold_delivered = "Sold delivered"
cls.product_expense_product.weekly_sold_delivered = "Sold delivered service"
cls.order = cls.env["sale.order"].create(
{
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
{
"product_id": cls.product.id,
"product_uom": cls.product.uom_id.id,
"product_uom_qty": 3.0,
},
),
(0, 0, {"display_type": "line_section", "name": "Section"}),
(
0,
0,
{
"product_id": cls.product_expense_product.id,
"product_uom": cls.product_expense_product.uom_id.id,
"product_uom_qty": 3.0,
},
),
],
}
)

def test_01_check_delivered_message_without_parameters(self):
"""Test the return message deppending on the type of the product."""
self.assertEqual(self.order.order_line[0].weekly_sold_delivered_shown, "◌◌◌◌◌◌")
self.assertEqual(self.order.order_line[1].weekly_sold_delivered_shown, False)

def test_02_check_delivered_message_with_parameters(self):
"""Test the definition of config parameters."""
self.env["ir.config_parameter"].create(
{
"key": "product_sold_by_delivery_week.sold_char",
"value": "R",
}
)
self.env["ir.config_parameter"].create(
{
"key": "product_sold_by_delivery_week.not_sold_char",
"value": "M",
}
)
self.assertEqual(self.order.order_line[0].weekly_sold_delivered_shown, "MMMMMM")
self.assertEqual(self.order.order_line[1].weekly_sold_delivered_shown, False)

def test_03_sale_stock_delivery_partial(self):
"""
Test a SO with a product on delivery.
"""
# intial order
self.order.action_confirm()
self.assertTrue(
self.order.picking_ids,
'Sale Stock: no picking created for "invoice on delivery" storable products',
)
pick = self.order.picking_ids
pick.move_lines.write({"quantity_done": 3})
pick.button_validate()
for line in pick.move_lines:
line._action_done()
self.assertEqual(line.product_id.weekly_sold_delivered, "Sold delivered")

0 comments on commit 53fd708

Please sign in to comment.