Skip to content

Commit

Permalink
[FIX]stock_picking_report_valued: Fix #305. Take currency field from …
Browse files Browse the repository at this point in the history
…company if not sale line related
  • Loading branch information
javierjcf committed Jun 27, 2024
1 parent a625484 commit 527c261
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions stock_picking_report_valued/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright 2016-2022 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import fields, models, api
from odoo.tools import float_compare


Expand All @@ -15,7 +15,9 @@ class StockMoveLine(models.Model):
related="move_id.sale_line_id", readonly=True, string="Related order line"
)
currency_id = fields.Many2one(
related="sale_line.currency_id", readonly=True, string="Sale Currency"
comodel_name="res.currency",
compute="_compute_sale_currency_id",
string="Sale Currency",
)
sale_tax_id = fields.Many2many(
related="sale_line.tax_id", readonly=True, string="Sale Tax"
Expand Down Expand Up @@ -44,6 +46,15 @@ class StockMoveLine(models.Model):
compute="_compute_sale_order_line_fields", string="Total", compute_sudo=True
)

@api.depends("sale_line", "company_id")
def _compute_sale_currency_id(self):
for line in self:
line.currency_id = (
line.sale_line.currency_id.id
if line.sale_line
else line.company_id.currency_id.id
)

def _get_report_valued_quantity(self):
return self.qty_done or self.reserved_qty

Expand Down

0 comments on commit 527c261

Please sign in to comment.