Merge pull request #413 from ForgeFlow/16.0-fix-rma_sml_product_uom_qty

[16.0][FIX] rma: multiple fixes
This commit is contained in:
Jordi Ballester Alomar
2023-07-07 19:00:19 +02:00
committed by GitHub
6 changed files with 47 additions and 22 deletions

View File

@@ -22,4 +22,6 @@ class ResPartner(models.Model):
action = self.env.ref("rma.action_rma_customer_lines") action = self.env.ref("rma.action_rma_customer_lines")
result = action.sudo().read()[0] result = action.sudo().read()[0]
result["context"] = {"search_default_partner_id": self.id} result["context"] = {"search_default_partner_id": self.id}
result["domain"] = []
result["display_name"] = "Partner RMAs"
return result return result

View File

@@ -68,7 +68,7 @@ class RmaOrderLine(models.Model):
if last_usage == "internal" and first_usage != "internal": if last_usage == "internal" and first_usage != "internal":
moves |= move moves |= move
elif last_usage == "supplier" and first_usage == "customer": elif last_usage == "supplier" and first_usage == "customer":
moves |= moves moves |= move
return moves return moves
@api.model @api.model
@@ -77,7 +77,10 @@ class RmaOrderLine(models.Model):
for move in self.move_ids: for move in self.move_ids:
first_usage = move._get_first_usage() first_usage = move._get_first_usage()
last_usage = move._get_last_usage() last_usage = move._get_last_usage()
if first_usage in ("internal", "production") and last_usage != "internal": if first_usage in ("internal", "production") and last_usage in (
"customer",
"supplier",
):
pickings |= move.picking_id pickings |= move.picking_id
elif last_usage == "customer" and first_usage == "supplier": elif last_usage == "customer" and first_usage == "supplier":
pickings |= move.picking_id pickings |= move.picking_id
@@ -98,12 +101,30 @@ class RmaOrderLine(models.Model):
product_obj = self.env["uom.uom"] product_obj = self.env["uom.uom"]
qty = 0.0 qty = 0.0
if direction == "in": if direction == "in":
op = ops["="] moves = rec.move_ids.filtered(
else: lambda m: m.state in states
op = ops["!="] and (
for move in rec.move_ids.filtered( m.location_id.usage == "supplier"
lambda m: m.state in states and op(m.location_id.usage, rec.type) or m.location_id.usage == "customer"
): )
and (
m.location_dest_id.usage == "internal"
or m.location_dest_id.usage == "supplier"
)
)
elif direction == "out":
moves = rec.move_ids.filtered(
lambda m: m.state in states
and (
m.location_dest_id.usage == "supplier"
or m.location_dest_id.usage == "customer"
)
and (
m.location_id.usage == "internal"
or m.location_id.usage == "supplier"
)
)
for move in moves:
# If the move is part of a chain don't count it # If the move is part of a chain don't count it
if direction == "out" and move.move_orig_ids: if direction == "out" and move.move_orig_ids:
continue continue

View File

@@ -387,7 +387,7 @@
<field name="lot_id" /> <field name="lot_id" />
<separator /> <separator />
<filter <filter
name="assigned_to" name="assigned_to_filter"
domain="[('assigned_to','=',uid)]" domain="[('assigned_to','=',uid)]"
help="My RMAs" help="My RMAs"
/> />
@@ -457,7 +457,7 @@
<field name="name">Customer RMA</field> <field name="name">Customer RMA</field>
<field name="res_model">rma.order.line</field> <field name="res_model">rma.order.line</field>
<field name="domain">[('type','=', 'customer')]</field> <field name="domain">[('type','=', 'customer')]</field>
<field name="context">{"search_default_assigned_to":uid}</field> <field name="context">{"search_default_assigned_to_filter":1}</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="view_id" ref="view_rma_line_tree" /> <field name="view_id" ref="view_rma_line_tree" />
</record> </record>
@@ -468,7 +468,7 @@
<field name="domain">[('type','=', 'supplier')]</field> <field name="domain">[('type','=', 'supplier')]</field>
<field <field
name="context" name="context"
>{"search_default_assigned_to":uid, "supplier":1}</field> >{"search_default_assigned_to_filter":1, "supplier":1}</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="view_id" ref="view_rma_line_supplier_tree" /> <field name="view_id" ref="view_rma_line_supplier_tree" />
</record> </record>

View File

@@ -18,9 +18,9 @@
<field name="inherit_id" ref="stock.stock_location_route_form_view" /> <field name="inherit_id" ref="stock.stock_location_route_form_view" />
<field name="model">stock.route</field> <field name="model">stock.route</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='warehouse_selectable']" position="before"> <label for="warehouse_selectable" position="before">
<field name="rma_selectable" string="RMA Order Lines" /> <field name="rma_selectable" string="RMA Order Lines" />
</xpath> </label>
</field> </field>
</record> </record>
</odoo> </odoo>

View File

@@ -102,17 +102,19 @@ class RmaMakePicking(models.TransientModel):
def _get_procurement_data(self, item, group, qty, picking_type): def _get_procurement_data(self, item, group, qty, picking_type):
line = item.line_id line = item.line_id
delivery_address_id = self._get_address(item) delivery_address_id = self._get_address(item)
location, warehouse, route = False, False, False
if picking_type == "incoming": if picking_type == "incoming":
if line.customer_to_supplier: if line.customer_to_supplier:
location = self._get_address_location(delivery_address_id, "supplier") location = self._get_address_location(delivery_address_id, "supplier")
elif line.supplier_to_customer:
location = self._get_address_location(delivery_address_id, "customer")
else: else:
location = line.location_id location = line.location_id
warehouse = line.in_warehouse_id warehouse = line.in_warehouse_id
route = line.in_route_id route = line.in_route_id
else: elif picking_type == "outgoing":
location = self._get_address_location(delivery_address_id, line.type) if line.supplier_to_customer:
location = self._get_address_location(delivery_address_id, "customer")
else:
location = self._get_address_location(delivery_address_id, line.type)
warehouse = line.out_warehouse_id warehouse = line.out_warehouse_id
route = line.out_route_id route = line.out_route_id
if not route: if not route:
@@ -227,7 +229,7 @@ class RmaMakePicking(models.TransientModel):
) )
move.move_line_ids.write( move.move_line_ids.write(
{ {
"product_uom_qty": 1, "reserved_uom_qty": 1,
"qty_done": 0, "qty_done": 0,
} }
) )

View File

@@ -108,26 +108,26 @@
name="%(action_rma_picking_in)d" name="%(action_rma_picking_in)d"
string="Create Incoming Shipment" string="Create Incoming Shipment"
class="oe_highlight" class="oe_highlight"
attrs="{'invisible':['|', '|', ('qty_to_receive', '=', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}" attrs="{'invisible':['|', '|', '|', ('qty_to_receive', '=', 0), ('qty_to_receive', '&lt;', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}"
type="action" type="action"
/> />
<button <button
name="%(action_rma_picking_in)d" name="%(action_rma_picking_in)d"
string="Create Incoming Shipment" string="Create Incoming Shipment"
attrs="{'invisible':['|', '|', ('qty_to_receive', '!=', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}" attrs="{'invisible':['|', '|', ('qty_to_receive', '>', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}"
type="action" type="action"
/> />
<button <button
name="%(action_rma_picking_out)d" name="%(action_rma_picking_out)d"
string="Create Delivery" string="Create Delivery"
class="oe_highlight" class="oe_highlight"
attrs="{'invisible':['|', '|', ('qty_to_deliver', '=', 0), ('state', '!=', 'approved'), ('delivery_policy', '=', 'no')]}" attrs="{'invisible':['|', '|', '|', ('qty_to_deliver', '=', 0), ('qty_to_deliver', '&lt;', 0), ('state', '!=', 'approved'), ('delivery_policy', '=', 'no')]}"
type="action" type="action"
/> />
<button <button
name="%(action_rma_picking_out)d" name="%(action_rma_picking_out)d"
string="Create Delivery" string="Create Delivery"
attrs="{'invisible':['|', '|', ('qty_to_deliver', '!=', 0), ('state', '!=', 'approved'), ('delivery_policy', '=', 'no')]}" attrs="{'invisible':['|', '|', ('qty_to_deliver', '>', 0), ('state', '!=', 'approved'), ('delivery_policy', '=', 'no')]}"
type="action" type="action"
/> />
</header> </header>