mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[16.0][MIG] Migrate rma module to v16
This commit is contained in:
committed by
JasminSForgeFlow
parent
855e3dcf1c
commit
5f9c24bb85
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "RMA (Return Merchandise Authorization)",
|
"name": "RMA (Return Merchandise Authorization)",
|
||||||
"version": "15.0.1.1.1",
|
"version": "16.0.1.0.0",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"category": "RMA",
|
"category": "RMA",
|
||||||
"summary": "Introduces the return merchandise authorization (RMA) process in odoo",
|
"summary": "Introduces the return merchandise authorization (RMA) process in odoo",
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
<field name="rma_sup_in_type_id" ref="picking_type_rma_sup_in" />
|
<field name="rma_sup_in_type_id" ref="picking_type_rma_sup_in" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="route_rma_customer" model='stock.location.route'>
|
<record id="route_rma_customer" model='stock.route'>
|
||||||
<field name="name">RMA Customer</field>
|
<field name="name">RMA Customer</field>
|
||||||
<field name="company_id" eval="0" />
|
<field name="company_id" eval="0" />
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
<field name="rma_selectable" eval="True" />
|
<field name="rma_selectable" eval="True" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="route_rma_supplier" model='stock.location.route'>
|
<record id="route_rma_supplier" model='stock.route'>
|
||||||
<field name="name">RMA Supplier</field>
|
<field name="name">RMA Supplier</field>
|
||||||
<field name="company_id" eval="0" />
|
<field name="company_id" eval="0" />
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
<field name="rma_selectable" eval="True" />
|
<field name="rma_selectable" eval="True" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="route_rma_dropship" model='stock.location.route'>
|
<record id="route_rma_dropship" model='stock.route'>
|
||||||
<field name="name">RMA Dropship</field>
|
<field name="name">RMA Dropship</field>
|
||||||
<field name="company_id" eval="0" />
|
<field name="company_id" eval="0" />
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0" />
|
<field name="warehouse_id" ref="stock.warehouse0" />
|
||||||
<field name="location_src_id" ref="stock.stock_location_customers" />
|
<field name="location_src_id" ref="stock.stock_location_customers" />
|
||||||
<field name="location_id" ref="rma.location_rma" />
|
<field name="location_dest_id" ref="rma.location_rma" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_customer" />
|
<field name="route_id" ref="rma.route_rma_customer" />
|
||||||
<field name="picking_type_id" ref="rma.picking_type_rma_cust_in" />
|
<field name="picking_type_id" ref="rma.picking_type_rma_cust_in" />
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0" />
|
<field name="warehouse_id" ref="stock.warehouse0" />
|
||||||
<field name="location_src_id" ref="rma.location_rma" />
|
<field name="location_src_id" ref="rma.location_rma" />
|
||||||
<field name="location_id" ref="stock.stock_location_customers" />
|
<field name="location_dest_id" ref="stock.stock_location_customers" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_customer" />
|
<field name="route_id" ref="rma.route_rma_customer" />
|
||||||
<field name="picking_type_id" ref="rma.picking_type_rma_cust_out" />
|
<field name="picking_type_id" ref="rma.picking_type_rma_cust_out" />
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
<field name="name">RMA → Supplier</field>
|
<field name="name">RMA → Supplier</field>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0" />
|
<field name="warehouse_id" ref="stock.warehouse0" />
|
||||||
<field name="location_id" ref="stock.stock_location_suppliers" />
|
<field name="location_dest_id" ref="stock.stock_location_suppliers" />
|
||||||
<field name="location_src_id" ref="rma.location_rma" />
|
<field name="location_src_id" ref="rma.location_rma" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_supplier" />
|
<field name="route_id" ref="rma.route_rma_supplier" />
|
||||||
@@ -176,7 +176,7 @@
|
|||||||
<field name="name">Supplier → RMA</field>
|
<field name="name">Supplier → RMA</field>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0" />
|
<field name="warehouse_id" ref="stock.warehouse0" />
|
||||||
<field name="location_id" ref="rma.location_rma" />
|
<field name="location_dest_id" ref="rma.location_rma" />
|
||||||
<field name="location_src_id" ref="stock.stock_location_suppliers" />
|
<field name="location_src_id" ref="stock.stock_location_suppliers" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_supplier" />
|
<field name="route_id" ref="rma.route_rma_supplier" />
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
<record id="rule_rma_dropship_return" model="stock.rule">
|
<record id="rule_rma_dropship_return" model="stock.rule">
|
||||||
<field name="name">Customer → Supplier</field>
|
<field name="name">Customer → Supplier</field>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="location_id" ref="stock.stock_location_suppliers" />
|
<field name="location_dest_id" ref="stock.stock_location_suppliers" />
|
||||||
<field name="location_src_id" ref="stock.stock_location_customers" />
|
<field name="location_src_id" ref="stock.stock_location_customers" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_dropship" />
|
<field name="route_id" ref="rma.route_rma_dropship" />
|
||||||
@@ -196,7 +196,7 @@
|
|||||||
<record id="rule_rma_dropship" model="stock.rule">
|
<record id="rule_rma_dropship" model="stock.rule">
|
||||||
<field name="name">Supplier → Customer</field>
|
<field name="name">Supplier → Customer</field>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="location_id" ref="stock.stock_location_customers" />
|
<field name="location_dest_id" ref="stock.stock_location_customers" />
|
||||||
<field name="location_src_id" ref="stock.stock_location_suppliers" />
|
<field name="location_src_id" ref="stock.stock_location_suppliers" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_dropship" />
|
<field name="route_id" ref="rma.route_rma_dropship" />
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!--Routes-->
|
<!--Routes-->
|
||||||
<record id="route_rma_customer" model="stock.location.route">
|
<record id="route_rma_customer" model="stock.route">
|
||||||
<field name="name">RMA Customer</field>
|
<field name="name">RMA Customer</field>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="product_selectable" eval="False" />
|
<field name="product_selectable" eval="False" />
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
<field name="rma_selectable" eval="True" />
|
<field name="rma_selectable" eval="True" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="route_rma_supplier" model="stock.location.route">
|
<record id="route_rma_supplier" model="stock.route">
|
||||||
<field name="name">RMA Supplier</field>
|
<field name="name">RMA Supplier</field>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="product_selectable" eval="False" />
|
<field name="product_selectable" eval="False" />
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<field name="rma_selectable" eval="True" />
|
<field name="rma_selectable" eval="True" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="route_rma_dropship" model="stock.location.route">
|
<record id="route_rma_dropship" model="stock.route">
|
||||||
<field name="name">RMA Dropship</field>
|
<field name="name">RMA Dropship</field>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="product_selectable" eval="False" />
|
<field name="product_selectable" eval="False" />
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
<field name="name">Customer → Supplier</field>
|
<field name="name">Customer → Supplier</field>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0" />
|
<field name="warehouse_id" ref="stock.warehouse0" />
|
||||||
<field name="location_id" ref="stock.stock_location_suppliers" />
|
<field name="location_dest_id" ref="stock.stock_location_suppliers" />
|
||||||
<field name="location_src_id" ref="stock.stock_location_customers" />
|
<field name="location_src_id" ref="stock.stock_location_customers" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_dropship" />
|
<field name="route_id" ref="rma.route_rma_dropship" />
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
<field name="name">Supplier → Customer</field>
|
<field name="name">Supplier → Customer</field>
|
||||||
<field name="action">pull</field>
|
<field name="action">pull</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0" />
|
<field name="warehouse_id" ref="stock.warehouse0" />
|
||||||
<field name="location_id" ref="stock.stock_location_customers" />
|
<field name="location_dest_id" ref="stock.stock_location_customers" />
|
||||||
<field name="location_src_id" ref="stock.stock_location_suppliers" />
|
<field name="location_src_id" ref="stock.stock_location_suppliers" />
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
<field name="route_id" ref="rma.route_rma_dropship" />
|
<field name="route_id" ref="rma.route_rma_dropship" />
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def set_rma_customer_operation_property(cr):
|
|
||||||
""" """
|
|
||||||
cr.execute(
|
|
||||||
"""
|
|
||||||
WITH rma_customer_operation_id_field AS (
|
|
||||||
SELECT id FROM ir_model_fields WHERE model='product.template'
|
|
||||||
AND name='rma_customer_operation_id'
|
|
||||||
)
|
|
||||||
INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
|
|
||||||
value_reference)
|
|
||||||
SELECT 'rma_customer_operation_id', 'many2one', rco.id, ro.company_id,
|
|
||||||
CONCAT('product.template,', t.id), CONCAT('rma.operation,', ro.id)
|
|
||||||
FROM product_template t JOIN rma_operation ro
|
|
||||||
ON t.rma_customer_operation_id = ro.id
|
|
||||||
, rma_customer_operation_id_field rco
|
|
||||||
WHERE ro.company_id IS NOT NULL
|
|
||||||
AND NOT EXISTS(SELECT 1
|
|
||||||
FROM ir_property
|
|
||||||
WHERE fields_id=rco.id
|
|
||||||
AND company_id=ro.company_id
|
|
||||||
AND res_id=CONCAT('product.template,', t.id))
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
_logger.info(
|
|
||||||
"Added %s rma_customer_operation_id_field product properties", cr.rowcount
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def set_rma_supplier_operation_property(cr):
|
|
||||||
""" """
|
|
||||||
cr.execute(
|
|
||||||
"""
|
|
||||||
WITH rma_supplier_operation_id_field AS (
|
|
||||||
SELECT id FROM ir_model_fields WHERE model='product.template'
|
|
||||||
AND name='rma_supplier_operation_id'
|
|
||||||
)
|
|
||||||
INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
|
|
||||||
value_reference)
|
|
||||||
SELECT 'rma_supplier_operation_id', 'many2one', rco.id, ro.company_id,
|
|
||||||
CONCAT('product.template,', t.id), CONCAT('rma.operation,', ro.id)
|
|
||||||
FROM product_template t JOIN rma_operation ro
|
|
||||||
ON t.rma_supplier_operation_id = ro.id
|
|
||||||
, rma_supplier_operation_id_field rco
|
|
||||||
WHERE ro.company_id IS NOT NULL
|
|
||||||
AND NOT EXISTS(SELECT 1
|
|
||||||
FROM ir_property
|
|
||||||
WHERE fields_id=rco.id
|
|
||||||
AND company_id=ro.company_id
|
|
||||||
AND res_id=CONCAT('product.template,', t.id))
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
_logger.info(
|
|
||||||
"Added %s rma_supplier_operation_id_field product properties", cr.rowcount
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def set_rma_customer_operation_category_property(cr):
|
|
||||||
""" """
|
|
||||||
cr.execute(
|
|
||||||
"""
|
|
||||||
WITH rma_customer_operation_id_field AS (
|
|
||||||
SELECT id FROM ir_model_fields WHERE model='product.category'
|
|
||||||
AND name='rma_customer_operation_id'
|
|
||||||
)
|
|
||||||
INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
|
|
||||||
value_reference)
|
|
||||||
SELECT 'rma_customer_operation_id', 'many2one', rco.id, ro.company_id,
|
|
||||||
CONCAT('product.category,', pc.id), CONCAT('rma.operation,', ro.id)
|
|
||||||
FROM product_category pc JOIN rma_operation ro
|
|
||||||
ON pc.rma_customer_operation_id = ro.id
|
|
||||||
, rma_customer_operation_id_field rco
|
|
||||||
WHERE ro.company_id IS NOT NULL
|
|
||||||
AND NOT EXISTS(SELECT 1
|
|
||||||
FROM ir_property
|
|
||||||
WHERE fields_id=rco.id
|
|
||||||
AND company_id=ro.company_id
|
|
||||||
AND res_id=CONCAT('product.category,', pc.id))
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
_logger.info(
|
|
||||||
"Added %s rma_customer_operation_id_field product category properties",
|
|
||||||
cr.rowcount,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def set_rma_supplier_operation_category_property(cr):
|
|
||||||
""" """
|
|
||||||
cr.execute(
|
|
||||||
"""
|
|
||||||
WITH rma_supplier_operation_id_field AS (
|
|
||||||
SELECT id FROM ir_model_fields WHERE model='product.category'
|
|
||||||
AND name='rma_supplier_operation_id'
|
|
||||||
)
|
|
||||||
INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
|
|
||||||
value_reference)
|
|
||||||
SELECT 'rma_supplier_operation_id', 'many2one', rco.id, ro.company_id,
|
|
||||||
CONCAT('product.category,', pc.id), CONCAT('rma.operation,', ro.id)
|
|
||||||
FROM product_category pc JOIN rma_operation ro
|
|
||||||
ON pc.rma_supplier_operation_id = ro.id
|
|
||||||
, rma_supplier_operation_id_field rco
|
|
||||||
WHERE ro.company_id IS NOT NULL
|
|
||||||
AND NOT EXISTS(SELECT 1
|
|
||||||
FROM ir_property
|
|
||||||
WHERE fields_id=rco.id
|
|
||||||
AND company_id=ro.company_id
|
|
||||||
AND res_id=CONCAT('product.category,', pc.id))
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
_logger.info(
|
|
||||||
"Added %s rma_supplier_operation_id_field product category properties",
|
|
||||||
cr.rowcount,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def migrate(cr, version=None):
|
|
||||||
if not version:
|
|
||||||
return
|
|
||||||
set_rma_customer_operation_property(cr)
|
|
||||||
set_rma_supplier_operation_property(cr)
|
|
||||||
set_rma_customer_operation_category_property(cr)
|
|
||||||
set_rma_supplier_operation_category_property(cr)
|
|
||||||
@@ -52,13 +52,13 @@ class RmaOperation(models.Model):
|
|||||||
default="no",
|
default="no",
|
||||||
)
|
)
|
||||||
in_route_id = fields.Many2one(
|
in_route_id = fields.Many2one(
|
||||||
comodel_name="stock.location.route",
|
comodel_name="stock.route",
|
||||||
string="Inbound Route",
|
string="Inbound Route",
|
||||||
domain=[("rma_selectable", "=", True)],
|
domain=[("rma_selectable", "=", True)],
|
||||||
default=lambda self: self._default_routes(),
|
default=lambda self: self._default_routes(),
|
||||||
)
|
)
|
||||||
out_route_id = fields.Many2one(
|
out_route_id = fields.Many2one(
|
||||||
comodel_name="stock.location.route",
|
comodel_name="stock.route",
|
||||||
string="Outbound Route",
|
string="Outbound Route",
|
||||||
domain=[("rma_selectable", "=", True)],
|
domain=[("rma_selectable", "=", True)],
|
||||||
default=lambda self: self._default_routes(),
|
default=lambda self: self._default_routes(),
|
||||||
|
|||||||
@@ -157,13 +157,18 @@ class RmaOrder(models.Model):
|
|||||||
if len(self.mapped("rma_line_ids.partner_id")) > 1:
|
if len(self.mapped("rma_line_ids.partner_id")) > 1:
|
||||||
raise UserError(_("All grouped RMA's should have same partner."))
|
raise UserError(_("All grouped RMA's should have same partner."))
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
if self.env.context.get("supplier") or vals.get("type") == "supplier":
|
for vals in vals_list:
|
||||||
vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.supplier")
|
if self.env.context.get("supplier") or vals.get("type") == "supplier":
|
||||||
else:
|
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||||
vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.customer")
|
"rma.order.supplier"
|
||||||
return super(RmaOrder, self).create(vals)
|
)
|
||||||
|
else:
|
||||||
|
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||||
|
"rma.order.customer"
|
||||||
|
)
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
def _view_shipments(self, result, shipments):
|
def _view_shipments(self, result, shipments):
|
||||||
# choose the view_mode accordingly
|
# choose the view_mode accordingly
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
product_tracking = fields.Selection(related="product_id.tracking")
|
product_tracking = fields.Selection(related="product_id.tracking")
|
||||||
lot_id = fields.Many2one(
|
lot_id = fields.Many2one(
|
||||||
comodel_name="stock.production.lot",
|
comodel_name="stock.lot",
|
||||||
string="Lot/Serial Number",
|
string="Lot/Serial Number",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
states={"draft": [("readonly", False)]},
|
states={"draft": [("readonly", False)]},
|
||||||
@@ -372,7 +372,7 @@ class RmaOrderLine(models.Model):
|
|||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
)
|
)
|
||||||
in_route_id = fields.Many2one(
|
in_route_id = fields.Many2one(
|
||||||
"stock.location.route",
|
"stock.route",
|
||||||
string="Inbound Route",
|
string="Inbound Route",
|
||||||
required=True,
|
required=True,
|
||||||
domain=[("rma_selectable", "=", True)],
|
domain=[("rma_selectable", "=", True)],
|
||||||
@@ -380,7 +380,7 @@ class RmaOrderLine(models.Model):
|
|||||||
states={"draft": [("readonly", False)]},
|
states={"draft": [("readonly", False)]},
|
||||||
)
|
)
|
||||||
out_route_id = fields.Many2one(
|
out_route_id = fields.Many2one(
|
||||||
"stock.location.route",
|
"stock.route",
|
||||||
string="Outbound Route",
|
string="Outbound Route",
|
||||||
required=True,
|
required=True,
|
||||||
domain=[("rma_selectable", "=", True)],
|
domain=[("rma_selectable", "=", True)],
|
||||||
@@ -513,7 +513,7 @@ class RmaOrderLine(models.Model):
|
|||||||
raise ValidationError(_("Please define an operation first."))
|
raise ValidationError(_("Please define an operation first."))
|
||||||
|
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env["stock.location.route"].search(
|
route = self.env["stock.route"].search(
|
||||||
[("rma_selectable", "=", True)], limit=1
|
[("rma_selectable", "=", True)], limit=1
|
||||||
)
|
)
|
||||||
if not route:
|
if not route:
|
||||||
@@ -597,7 +597,7 @@ class RmaOrderLine(models.Model):
|
|||||||
self.reference_move_id = False
|
self.reference_move_id = False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _check_production_lot_assigned(self):
|
def _check_lot_assigned(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.product_id.tracking == "serial" and rec.product_qty != 1:
|
if rec.product_id.tracking == "serial" and rec.product_qty != 1:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
@@ -609,7 +609,7 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def action_rma_to_approve(self):
|
def action_rma_to_approve(self):
|
||||||
self._check_production_lot_assigned()
|
self._check_lot_assigned()
|
||||||
self.write({"state": "to_approve"})
|
self.write({"state": "to_approve"})
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.product_id.rma_approval_policy == "one_step":
|
if rec.product_id.rma_approval_policy == "one_step":
|
||||||
@@ -628,18 +628,19 @@ class RmaOrderLine(models.Model):
|
|||||||
self.write({"state": "done"})
|
self.write({"state": "done"})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
if not vals.get("name") or vals.get("name") == "/":
|
for vals in vals_list:
|
||||||
if self.env.context.get("supplier"):
|
if not vals.get("name") or vals.get("name") == "/":
|
||||||
vals["name"] = self.env["ir.sequence"].next_by_code(
|
if self.env.context.get("supplier"):
|
||||||
"rma.order.line.supplier"
|
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||||
)
|
"rma.order.line.supplier"
|
||||||
else:
|
)
|
||||||
vals["name"] = self.env["ir.sequence"].next_by_code(
|
else:
|
||||||
"rma.order.line.customer"
|
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||||
)
|
"rma.order.line.customer"
|
||||||
return super(RmaOrderLine, self).create(vals)
|
)
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
def _get_price_unit(self):
|
def _get_price_unit(self):
|
||||||
"""The price unit corresponds to the cost of that product"""
|
"""The price unit corresponds to the cost of that product"""
|
||||||
|
|||||||
@@ -11,16 +11,17 @@ class StockMove(models.Model):
|
|||||||
"rma.order.line", string="RMA line", ondelete="restrict"
|
"rma.order.line", string="RMA line", ondelete="restrict"
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
if vals.get("group_id"):
|
for vals in vals_list:
|
||||||
group = self.env["procurement.group"].browse(vals["group_id"])
|
if vals.get("group_id"):
|
||||||
if group.rma_line_id:
|
group = self.env["procurement.group"].browse(vals["group_id"])
|
||||||
vals["rma_line_id"] = group.rma_line_id.id
|
if group.rma_line_id:
|
||||||
return super(StockMove, self).create(vals)
|
vals["rma_line_id"] = group.rma_line_id.id
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
def _action_assign(self):
|
def _action_assign(self, force_qty=False):
|
||||||
res = super(StockMove, self)._action_assign()
|
res = super()._action_assign(force_qty=force_qty)
|
||||||
for move in self:
|
for move in self:
|
||||||
if move.rma_line_id:
|
if move.rma_line_id:
|
||||||
move.partner_id = move.rma_line_id.partner_id.id or False
|
move.partner_id = move.rma_line_id.partner_id.id or False
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class StockWarehouse(models.Model):
|
|||||||
"warehouse_id": self.id,
|
"warehouse_id": self.id,
|
||||||
"company_id": self.company_id.id,
|
"company_id": self.company_id.id,
|
||||||
"location_src_id": customer_loc.id,
|
"location_src_id": customer_loc.id,
|
||||||
"location_id": self.lot_rma_id.id,
|
"location_dest_id": self.lot_rma_id.id,
|
||||||
"procure_method": "make_to_stock",
|
"procure_method": "make_to_stock",
|
||||||
"route_id": self.env.ref("rma.route_rma_customer").id,
|
"route_id": self.env.ref("rma.route_rma_customer").id,
|
||||||
"picking_type_id": self.rma_cust_in_type_id.id,
|
"picking_type_id": self.rma_cust_in_type_id.id,
|
||||||
@@ -197,7 +197,7 @@ class StockWarehouse(models.Model):
|
|||||||
"warehouse_id": self.id,
|
"warehouse_id": self.id,
|
||||||
"company_id": self.company_id.id,
|
"company_id": self.company_id.id,
|
||||||
"location_src_id": self.lot_rma_id.id,
|
"location_src_id": self.lot_rma_id.id,
|
||||||
"location_id": customer_loc.id,
|
"location_dest_id": customer_loc.id,
|
||||||
"procure_method": "make_to_stock",
|
"procure_method": "make_to_stock",
|
||||||
"route_id": self.env.ref("rma.route_rma_customer").id,
|
"route_id": self.env.ref("rma.route_rma_customer").id,
|
||||||
"picking_type_id": self.rma_cust_out_type_id.id,
|
"picking_type_id": self.rma_cust_out_type_id.id,
|
||||||
@@ -209,7 +209,7 @@ class StockWarehouse(models.Model):
|
|||||||
"warehouse_id": self.id,
|
"warehouse_id": self.id,
|
||||||
"company_id": self.company_id.id,
|
"company_id": self.company_id.id,
|
||||||
"location_src_id": supplier_loc.id,
|
"location_src_id": supplier_loc.id,
|
||||||
"location_id": self.lot_rma_id.id,
|
"location_dest_id": self.lot_rma_id.id,
|
||||||
"procure_method": "make_to_stock",
|
"procure_method": "make_to_stock",
|
||||||
"route_id": self.env.ref("rma.route_rma_supplier").id,
|
"route_id": self.env.ref("rma.route_rma_supplier").id,
|
||||||
"picking_type_id": self.rma_sup_in_type_id.id,
|
"picking_type_id": self.rma_sup_in_type_id.id,
|
||||||
@@ -221,7 +221,7 @@ class StockWarehouse(models.Model):
|
|||||||
"warehouse_id": self.id,
|
"warehouse_id": self.id,
|
||||||
"company_id": self.company_id.id,
|
"company_id": self.company_id.id,
|
||||||
"location_src_id": self.lot_rma_id.id,
|
"location_src_id": self.lot_rma_id.id,
|
||||||
"location_id": supplier_loc.id,
|
"location_dest_id": supplier_loc.id,
|
||||||
"procure_method": "make_to_stock",
|
"procure_method": "make_to_stock",
|
||||||
"route_id": self.env.ref("rma.route_rma_supplier").id,
|
"route_id": self.env.ref("rma.route_rma_supplier").id,
|
||||||
"picking_type_id": self.rma_sup_out_type_id.id,
|
"picking_type_id": self.rma_sup_out_type_id.id,
|
||||||
@@ -264,6 +264,6 @@ class StockWarehouse(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class StockLocationRoute(models.Model):
|
class StockLocationRoute(models.Model):
|
||||||
_inherit = "stock.location.route"
|
_inherit = "stock.route"
|
||||||
|
|
||||||
rma_selectable = fields.Boolean(string="Selectable on RMA Lines")
|
rma_selectable = fields.Boolean(string="Selectable on RMA Lines")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
>
|
>
|
||||||
<t
|
<t
|
||||||
t-set="has_rma"
|
t-set="has_rma"
|
||||||
t-value="bool(o.move_lines.filtered(lambda m: m.rma_line_id))"
|
t-value="bool(o.move_ids.filtered(lambda m: m.rma_line_id))"
|
||||||
/>
|
/>
|
||||||
<th t-if="has_rma" name="th_sm_rma_line"><strong>RMA</strong></th>
|
<th t-if="has_rma" name="th_sm_rma_line"><strong>RMA</strong></th>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class TestRma(common.TransactionCase):
|
|||||||
res = rma_line_ids.action_view_in_shipments()
|
res = rma_line_ids.action_view_in_shipments()
|
||||||
picking = cls.env["stock.picking"].browse(res["res_id"])
|
picking = cls.env["stock.picking"].browse(res["res_id"])
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_ids:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking._action_done()
|
picking._action_done()
|
||||||
return picking
|
return picking
|
||||||
@@ -127,7 +127,7 @@ class TestRma(common.TransactionCase):
|
|||||||
res = rma_line_ids.action_view_out_shipments()
|
res = rma_line_ids.action_view_out_shipments()
|
||||||
picking = cls.env["stock.picking"].browse(res["res_id"])
|
picking = cls.env["stock.picking"].browse(res["res_id"])
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_ids:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking._action_done()
|
picking._action_done()
|
||||||
return picking
|
return picking
|
||||||
@@ -167,7 +167,7 @@ class TestRma(common.TransactionCase):
|
|||||||
"""Do picking with only one move on the given date."""
|
"""Do picking with only one move on the given date."""
|
||||||
picking.action_confirm()
|
picking.action_confirm()
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
for ml in picking.move_lines:
|
for ml in picking.move_ids:
|
||||||
ml.filtered(
|
ml.filtered(
|
||||||
lambda m: m.state != "waiting"
|
lambda m: m.state != "waiting"
|
||||||
).quantity_done = ml.product_uom_qty
|
).quantity_done = ml.product_uom_qty
|
||||||
@@ -414,7 +414,7 @@ class TestRma(common.TransactionCase):
|
|||||||
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
|
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
|
||||||
picking = self.env["stock.picking"].browse(res["res_id"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
self.assertEqual(len(picking), 1, "Incorrect number of pickings created")
|
self.assertEqual(len(picking), 1, "Incorrect number of pickings created")
|
||||||
moves = picking.move_lines
|
moves = picking.move_ids
|
||||||
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
||||||
lines = self.rma_customer_id.rma_line_ids
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
lines.refresh()
|
lines.refresh()
|
||||||
@@ -474,7 +474,7 @@ class TestRma(common.TransactionCase):
|
|||||||
"Wrong qty incoming",
|
"Wrong qty incoming",
|
||||||
)
|
)
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_ids:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking._action_done()
|
picking._action_done()
|
||||||
lines = self.rma_customer_id.rma_line_ids
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
@@ -534,7 +534,7 @@ class TestRma(common.TransactionCase):
|
|||||||
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
|
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
|
||||||
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
|
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
|
||||||
picking = self.env["stock.picking"].browse(res["res_id"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
moves = picking.move_lines
|
moves = picking.move_ids
|
||||||
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
||||||
lines = self.rma_customer_id.rma_line_ids
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
lines.refresh()
|
lines.refresh()
|
||||||
@@ -593,7 +593,7 @@ class TestRma(common.TransactionCase):
|
|||||||
"Wrong qty outgoing",
|
"Wrong qty outgoing",
|
||||||
)
|
)
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_ids:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking._action_done()
|
picking._action_done()
|
||||||
lines = self.rma_customer_id.rma_line_ids
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
@@ -668,7 +668,7 @@ class TestRma(common.TransactionCase):
|
|||||||
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
|
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
|
||||||
picking = self.env["stock.picking"].browse(res["res_id"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
self.assertEqual(len(picking), 1, "Incorrect number of pickings created")
|
self.assertEqual(len(picking), 1, "Incorrect number of pickings created")
|
||||||
moves = picking.move_lines
|
moves = picking.move_ids
|
||||||
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
||||||
lines = self.rma_droship_id.rma_line_ids
|
lines = self.rma_droship_id.rma_line_ids
|
||||||
lines.refresh()
|
lines.refresh()
|
||||||
@@ -767,7 +767,7 @@ class TestRma(common.TransactionCase):
|
|||||||
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
|
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
|
||||||
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
|
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
|
||||||
picking = self.env["stock.picking"].browse(res["res_id"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
moves = picking.move_lines
|
moves = picking.move_ids
|
||||||
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
||||||
|
|
||||||
lines = self.rma_supplier_id.rma_line_ids
|
lines = self.rma_supplier_id.rma_line_ids
|
||||||
@@ -823,7 +823,7 @@ class TestRma(common.TransactionCase):
|
|||||||
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
|
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
|
||||||
)
|
)
|
||||||
picking.action_assign()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_ids:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking._action_done()
|
picking._action_done()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@@ -886,7 +886,7 @@ class TestRma(common.TransactionCase):
|
|||||||
pickings = self.env["stock.picking"].browse(res["res_id"])
|
pickings = self.env["stock.picking"].browse(res["res_id"])
|
||||||
self.assertEqual(len(pickings), 1, "Incorrect number of pickings created")
|
self.assertEqual(len(pickings), 1, "Incorrect number of pickings created")
|
||||||
picking_in = pickings[0]
|
picking_in = pickings[0]
|
||||||
moves = picking_in.move_lines
|
moves = picking_in.move_ids
|
||||||
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
|
||||||
|
|
||||||
lines = self.rma_supplier_id.rma_line_ids
|
lines = self.rma_supplier_id.rma_line_ids
|
||||||
@@ -925,7 +925,7 @@ class TestRma(common.TransactionCase):
|
|||||||
picking_in.action_confirm()
|
picking_in.action_confirm()
|
||||||
picking_in.action_assign()
|
picking_in.action_assign()
|
||||||
for mv in picking_in.move_line_ids:
|
for mv in picking_in.move_line_ids:
|
||||||
mv.qty_done = mv.product_uom_qty
|
mv.qty_done = mv.reserved_uom_qty
|
||||||
picking_in._action_done()
|
picking_in._action_done()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
|
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="stock_location_route_form_view_inherit_rma_stock" model="ir.ui.view">
|
<record id="stock_location_route_form_view_inherit_rma_stock" model="ir.ui.view">
|
||||||
<field name="name">stock.location.route.form</field>
|
<field name="name">stock.route.form</field>
|
||||||
<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.location.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">
|
<xpath expr="//field[@name='warehouse_selectable']" position="before">
|
||||||
<field name="rma_selectable" string="RMA Order Lines" />
|
<field name="rma_selectable" string="RMA Order Lines" />
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class RmaAddSerialWiz(models.TransientModel):
|
|||||||
comodel_name="res.partner",
|
comodel_name="res.partner",
|
||||||
)
|
)
|
||||||
lot_ids = fields.Many2many(
|
lot_ids = fields.Many2many(
|
||||||
comodel_name="stock.production.lot",
|
comodel_name="stock.lot",
|
||||||
string="Lots/Serials selected",
|
string="Lots/Serials selected",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class RmaAddSerialWiz(models.TransientModel):
|
|||||||
raise ValidationError(_("Please define an operation first"))
|
raise ValidationError(_("Please define an operation first"))
|
||||||
|
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env["stock.location.route"].search(
|
route = self.env["stock.route"].search(
|
||||||
[("rma_selectable", "=", True)], limit=1
|
[("rma_selectable", "=", True)], limit=1
|
||||||
)
|
)
|
||||||
if not route:
|
if not route:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
compute="_compute_lot_domain",
|
compute="_compute_lot_domain",
|
||||||
)
|
)
|
||||||
lot_domain_ids = fields.Many2many(
|
lot_domain_ids = fields.Many2many(
|
||||||
comodel_name="stock.production.lot",
|
comodel_name="stock.lot",
|
||||||
string="Lots Domain",
|
string="Lots Domain",
|
||||||
compute="_compute_lot_domain",
|
compute="_compute_lot_domain",
|
||||||
)
|
)
|
||||||
@@ -54,9 +54,7 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
rec.lot_domain_ids = rec.mapped("move_ids.move_line_ids.lot_id").ids
|
rec.lot_domain_ids = rec.mapped("move_ids.move_line_ids.lot_id").ids
|
||||||
rec.show_lot_filter = bool(rec.lot_domain_ids)
|
rec.show_lot_filter = bool(rec.lot_domain_ids)
|
||||||
|
|
||||||
lot_ids = fields.Many2many(
|
lot_ids = fields.Many2many(comodel_name="stock.lot", string="Lots/Serials selected")
|
||||||
comodel_name="stock.production.lot", string="Lots/Serials selected"
|
|
||||||
)
|
|
||||||
|
|
||||||
def select_all(self):
|
def select_all(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
@@ -93,7 +91,7 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
raise ValidationError(_("Please define an operation first"))
|
raise ValidationError(_("Please define an operation first"))
|
||||||
|
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env["stock.location.route"].search(
|
route = self.env["stock.route"].search(
|
||||||
[("rma_selectable", "=", True)], limit=1
|
[("rma_selectable", "=", True)], limit=1
|
||||||
)
|
)
|
||||||
if not route:
|
if not route:
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
if picking_type == "incoming":
|
if picking_type == "incoming":
|
||||||
# Force the reservation of the RMA specific lot for incoming shipments.
|
# Force the reservation of the RMA specific lot for incoming shipments.
|
||||||
# FIXME: still needs fixing, not reserving appropriate serials.
|
# FIXME: still needs fixing, not reserving appropriate serials.
|
||||||
for move in pickings.move_lines.filtered(
|
for move in pickings.move_ids.filtered(
|
||||||
lambda x: x.state not in ("draft", "cancel", "done")
|
lambda x: x.state not in ("draft", "cancel", "done")
|
||||||
and x.rma_line_id
|
and x.rma_line_id
|
||||||
and x.product_id.tracking in ("lot", "serial")
|
and x.product_id.tracking in ("lot", "serial")
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
operation = self._get_default_operation()
|
operation = self._get_default_operation()
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env["stock.location.route"].search(
|
route = self.env["stock.route"].search(
|
||||||
[("rma_selectable", "=", True)], limit=1
|
[("rma_selectable", "=", True)], limit=1
|
||||||
)
|
)
|
||||||
if not route:
|
if not route:
|
||||||
|
|||||||
Reference in New Issue
Block a user