Skip to content

Commit

Permalink
Merge PR #10 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by andhit-r
  • Loading branch information
ssi-bot committed Jan 8, 2024
2 parents ebec060 + 4d7cdbd commit cdbb3d4
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions ssi_rma/models/rma_line_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,26 @@ def onchange_lot_id(self):
def onchange_price_unit(self):
_super = super(RMALineMixin, self)
self.price_unit = 0.0
Quant = self.env["stock.quant"]
if self.lot_id and self.uom_quantity and self.uom_quantity != 0.0:
self.price_unit = 7.0
if self.lot_id.quant_ids:

quant = self.lot_id.quant_ids[-1]
self.price_unit = quant.value / self.uom_quantity
self.price_unit = 0.0
if self.order_id.type == "customer":
location = self.order_id.partner_id.property_stock_customer
else:
location = self.order_id.route_template_id.location_id
criteria = [
("product_id", "=", self.product_id.id),
("lot_id", "=", self.lot_id.id),
("location_id", "=", location.id),
]
quants = Quant.search(criteria)

if quants:
quant = quants[-1]
self.price_unit = (
quant.with_context(bypass_location_restriction=True).value
/ self.uom_quantity
)
else:
_super.onchange_price_unit()

Expand Down

0 comments on commit cdbb3d4

Please sign in to comment.