Merge PR #193 into 13.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2020-12-22 16:50:25 +00:00
5 changed files with 30 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ class SaleOrder(models.Model):
{
"product_id": data["product"].id,
"quantity": data["quantity"],
"sale_line_id": data["sale_line_id"].id,
"uom_id": data["uom"].id,
"picking_id": data["picking"] and data["picking"].id,
},
@@ -83,7 +84,7 @@ class SaleOrderLine(models.Model):
self.ensure_one()
return self.move_ids.filtered(
lambda r: (
self.product_id == r.product_id
self == r.sale_line_id
and r.state == "done"
and not r.scrapped
and r.location_dest_id.usage == "customer"
@@ -114,6 +115,7 @@ class SaleOrderLine(models.Model):
"quantity": qty,
"uom": move.product_uom,
"picking": move.picking_id,
"sale_line_id": self,
}
)
else:
@@ -123,6 +125,7 @@ class SaleOrderLine(models.Model):
"quantity": self.qty_delivered,
"uom": self.product_uom,
"picking": False,
"sale_line_id": self,
}
)
return data

View File

@@ -87,7 +87,9 @@
</thead>
<tbody class="request-rma-tbody">
<t t-foreach="data_list" t-as="data">
<t t-if="data['quantity'] > 0">
<t
t-if="data['quantity'] > 0 and data['picking']"
>
<tr>
<td class="text-left">
<span
@@ -98,6 +100,12 @@
t-attf-name="#{data_index}-product_id"
t-att-value="data['product'].id"
/>
<input
type="hidden"
t-if="data.get('sale_line_id')"
t-attf-name="#{data_index}-sale_line_id"
t-att-value="data['sale_line_id'].id"
/>
</td>
<td class="text-right">
<div id="delivery-rma-qty">
@@ -124,7 +132,6 @@
</td>
<td class="text-left">
<span
t-if="data['picking']"
t-esc="data['picking'].name"
/>
<input

View File

@@ -53,6 +53,8 @@ class SaleOrderRmaWizard(models.TransientModel):
def create_and_open_rma(self):
self.ensure_one()
rma = self.create_rma()
if not rma:
return
for rec in rma:
rec.action_confirm()
action = self.env.ref("rma.rma_action").read()[0]
@@ -109,11 +111,13 @@ class SaleOrderLineRmaWizard(models.TransientModel):
operation_id = fields.Many2one(
comodel_name="rma.operation", string="Requested operation",
)
sale_line_id = fields.Many2one(comodel_name="sale.order.line",)
description = fields.Text()
@api.onchange("product_id")
def onchange_product_id(self):
self.picking_id = False
self.uom_id = self.product_id.uom_id
@api.depends("picking_id")
def _compute_move_id(self):
@@ -121,7 +125,8 @@ class SaleOrderLineRmaWizard(models.TransientModel):
if record.picking_id:
record.move_id = record.picking_id.move_lines.filtered(
lambda r: (
r.sale_line_id.product_id == record.product_id
r.sale_line_id == record.sale_line_id
and r.sale_line_id.product_id == record.product_id
and r.sale_line_id.order_id == record.order_id
)
)

View File

@@ -23,10 +23,19 @@ class WebsiteRMA(http.Controller):
"""Domain used for the products to be shown in selection of
the web form.
"""
return [
domain = [
("name", "=ilike", "%{}%".format(q or "")),
("sale_ok", "=", True),
]
# HACK: As there is no glue module for this purpose we have put
# this this condition to check that the mrp module is installed.
if "bom_ids" in request.env["product.product"]._fields:
domain += [
"|",
("bom_ids.type", "!=", "phantom"),
("bom_ids", "=", False),
]
return domain
@http.route(["/requestrma"], type="http", auth="user", website=True)
def request_rma(self, **kw):

View File

@@ -12,5 +12,6 @@ class Rma(models.Model):
team_id=values.get("team_id") or request.website.rma_default_team_id.id,
user_id=values.get("user_id") or request.website.rma_default_user_id.id,
partner_id=values.get("partner_id") or request.env.user.partner_id.id,
origin="Website form",
)
return values