Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]stock_picking_report_valued: Fix #305. Avoid error when no sale line is linked to move line. #329

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 api, fields, models
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):
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
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
Loading