Skip to content

Commit

Permalink
[MIG] sale_report_delivered: Migration to version 18.0
Browse files Browse the repository at this point in the history
TT54301
  • Loading branch information
pilarvargas-tecnativa committed Feb 4, 2025
1 parent 267391f commit d9585c7
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 23 deletions.
1 change: 1 addition & 0 deletions sale_report_delivered/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Contributors

- Sergio Teruel
- Carlos Dauden
- Pilar Vargas

- Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)

Expand Down
2 changes: 1 addition & 1 deletion sale_report_delivered/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Sale Report Delivered",
"version": "16.0.2.1.0",
"version": "18.0.1.0.0",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-reporting",
"category": "Sales",
Expand Down
1 change: 1 addition & 0 deletions sale_report_delivered/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

> - Sergio Teruel
> - Carlos Dauden
> - Pilar Vargas
- Eduardo de Miguel ([Moduon](https://www.moduon.team/))
2 changes: 1 addition & 1 deletion sale_report_delivered/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import sale_report
from . import sale_report_delivered
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ class SaleReportDeliverd(models.Model):
categ_id = fields.Many2one("product.category", "Product Category", readonly=True)
nbr = fields.Integer("# of Lines", readonly=True)
pricelist_id = fields.Many2one("product.pricelist", "Pricelist", readonly=True)
analytic_account_id = fields.Many2one(
"account.analytic.account", "Analytic Account", readonly=True
)
team_id = fields.Many2one("crm.team", "Sales Team", readonly=True)
country_id = fields.Many2one("res.country", "Customer Country", readonly=True)
industry_id = fields.Many2one(
Expand All @@ -42,10 +39,9 @@ class SaleReportDeliverd(models.Model):
)
state = fields.Selection(
[
("draft", "Draft Quotation"),
("draft", "Quotation"),
("sent", "Quotation Sent"),
("sale", "Sales Order"),
("done", "Sales Done"),
("cancel", "Cancelled"),
],
string="Status",
Expand Down Expand Up @@ -82,7 +78,6 @@ def _select(self):
sub.source_id,
sub.categ_id,
sub.pricelist_id,
sub.analytic_account_id ,
sub.team_id,
sub.product_tmpl_id,
sub.country_id,
Expand Down Expand Up @@ -145,19 +140,27 @@ def _sub_select(self):
t.name as template_name,
t.uom_id as product_uom,
cur.decimal_places,
sm.quantity as unsigned_product_uom_qty,
CASE
WHEN dest_location.usage IS NULL
THEN 1
{self._sub_select_signed_qty()}
ELSE 0
END AS signed_qty,
(CASE WHEN t.type IN ('product', 'consu') THEN COALESCE(sm.product_uom_qty, 0.0)
ELSE sol.product_uom_qty END) / u.factor *
u2.factor as unsigned_product_uom_qty,
ROUND(COALESCE(sm.product_uom_qty * sol.price_reduce, sol.price_subtotal) /
CASE COALESCE(s.currency_rate, 0)
WHEN 0 THEN 1.0 ELSE s.currency_rate END, cur.decimal_places)
as unsigned_price_subtotal,
ROUND(
COALESCE(
sm.quantity * (
sol.price_unit * (1.0 - sol.discount / 100.0)
),
sol.price_subtotal
) /
CASE
COALESCE(s.currency_rate, 0)
WHEN 0 THEN 1.0
ELSE s.currency_rate
END,
cur.decimal_places
) as unsigned_price_subtotal,
s.name as order_name,
COALESCE(sm.date, s.effective_date, s.date_order) as date,
s.state as state,
Expand All @@ -169,15 +172,14 @@ def _sub_select(self):
s.source_id as source_id,
t.categ_id as categ_id,
s.pricelist_id as pricelist_id,
s.analytic_account_id as analytic_account_id,
s.team_id as team_id,
p.product_tmpl_id,
partner.user_id as user_from_partner_id,
partner.country_id as country_id,
partner.industry_id as industry_id,
partner.commercial_partner_id as commercial_partner_id,
p.weight * sm.product_uom_qty / u.factor * u2.factor as weight,
p.volume * sm.product_uom_qty / u.factor * u2.factor as volume,
p.weight * sm.quantity / u.factor * u2.factor as weight,
p.volume * sm.quantity / u.factor * u2.factor as volume,
s.id as order_id,
sp.id as picking_id,
sol.purchase_price AS unsigned_purchase_price,
Expand Down Expand Up @@ -262,7 +264,6 @@ def _group_by(self):
sub.medium_id,
sub.source_id,
sub.pricelist_id,
sub.analytic_account_id,
sub.team_id,
sub.product_tmpl_id,
sub.country_id,
Expand Down
1 change: 0 additions & 1 deletion sale_report_delivered/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_report_delivered_manager,sale.report.delivered,model_sale_report_delivered,sales_team.group_sale_manager,1,1,1,1
access_sale_report_delivered_salesman,sale.report.delivered,model_sale_report_delivered,sales_team.group_sale_salesman,1,0,0,0
1 change: 1 addition & 0 deletions sale_report_delivered/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Sergio Teruel</li>
<li>Carlos Dauden</li>
<li>Pilar Vargas</li>
</ul>
</blockquote>
</li>
Expand Down
9 changes: 7 additions & 2 deletions sale_report_delivered/tests/test_sale_report_delivered.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ def setUpClass(cls):
group_sale_manager.write({"users": [(4, cls.admin.id)]})

cls.product = cls.env["product.product"].create(
{"name": "Test product", "type": "product", "list_price": 10}
{
"name": "Test product",
"type": "consu",
"is_storable": True,
"list_price": 10,
}
)
cls._create_stock_quant(cls, cls.product)
cls.service = cls.env["product.product"].create(
Expand All @@ -41,7 +46,7 @@ def setUpClass(cls):
cls.orders = cls.order_1 + cls.order_2
cls.orders.action_confirm()
cls.orders.picking_ids.action_confirm()
cls.orders.picking_ids.move_ids.write({"quantity_done": 1.0})
cls.orders.picking_ids.move_ids.write({"quantity": 1.0})
cls.orders.picking_ids.button_validate()

def _create_stock_quant(self, product):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
name="year"
invisible="0"
date="date"
default_period="this_year"
default_period="year"
/>
<separator />
<filter
Expand Down

0 comments on commit d9585c7

Please sign in to comment.