mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
@@ -37,6 +37,7 @@ class SaleOrder(models.Model):
|
||||
line_vals = [(0, 0, {
|
||||
'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,
|
||||
}) for data in self.get_delivery_rma_data()]
|
||||
@@ -84,7 +85,7 @@ class SaleOrderLine(models.Model):
|
||||
def get_delivery_move(self):
|
||||
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"
|
||||
@@ -107,10 +108,11 @@ class SaleOrderLine(models.Model):
|
||||
'assigned', 'done'])
|
||||
qty -= sum(move_dest.mapped('product_uom_qty'))
|
||||
data.append({
|
||||
'product': product,
|
||||
'product': move.product_id,
|
||||
'quantity': qty,
|
||||
'uom': move.product_uom,
|
||||
'picking': move.picking_id,
|
||||
'sale_line_id': self,
|
||||
})
|
||||
else:
|
||||
data.append({
|
||||
@@ -118,5 +120,6 @@ class SaleOrderLine(models.Model):
|
||||
'quantity': self.qty_delivered,
|
||||
'uom': self.product_uom,
|
||||
'picking': False,
|
||||
'sale_line_id': self,
|
||||
})
|
||||
return data
|
||||
|
||||
@@ -67,13 +67,17 @@
|
||||
</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 t-esc="data['product'].display_name"/>
|
||||
<input type="hidden"
|
||||
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">
|
||||
@@ -92,12 +96,10 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-left">
|
||||
<t t-if="data['picking']">
|
||||
<span t-esc="data['picking'].name"/>
|
||||
<input type="hidden"
|
||||
t-attf-name="#{data_index}-picking_id"
|
||||
t-att-value="data['picking'].id"/>
|
||||
</t>
|
||||
<span t-esc="data['picking'].name"/>
|
||||
<input type="hidden"
|
||||
t-attf-name="#{data_index}-picking_id"
|
||||
t-att-value="data['picking'].id"/>
|
||||
</td>
|
||||
<td class="text-left">
|
||||
<select t-attf-name="#{data_index}-operation_id"
|
||||
|
||||
@@ -62,6 +62,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]
|
||||
@@ -132,19 +134,25 @@ class SaleOrderLineRmaWizard(models.TransientModel):
|
||||
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):
|
||||
for record in self:
|
||||
if record.picking_id:
|
||||
record.move_id = record.picking_id.move_lines.filtered(
|
||||
lambda r: (r.sale_line_id.product_id == record.product_id
|
||||
and r.sale_line_id.order_id == record.order_id))
|
||||
lambda r: (
|
||||
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))
|
||||
|
||||
@api.depends('order_id')
|
||||
def _compute_allowed_product_ids(self):
|
||||
|
||||
@@ -11,6 +11,7 @@ class WebsiteForm(WebsiteForm):
|
||||
def insert_record(self, request, model, values, custom, meta=None):
|
||||
if model.model == 'rma':
|
||||
values['partner_id'] = request.env.user.partner_id.id
|
||||
values['origin'] = 'Website form'
|
||||
res = super(WebsiteForm, self).insert_record(
|
||||
request, model, values, custom, meta)
|
||||
# Add the customer to the followers, the same as when creating
|
||||
@@ -26,10 +27,19 @@ class WebsiteRMA(http.Controller):
|
||||
"""Domain used for the products to be shown in selection of
|
||||
the web form.
|
||||
"""
|
||||
return [
|
||||
('name', '=ilike', "%{}%".format(q or '')),
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user