[MIG] rma: Migration to v17

This commit is contained in:
Carlos Vallés Fuster
2024-05-06 17:08:18 +02:00
committed by AaronHForgeFlow
parent e23335cee5
commit cb5a8a1ddd
19 changed files with 193 additions and 217 deletions

View File

@@ -7,7 +7,7 @@ RMA (Return Merchandise Authorization)
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:51ec7a60674dede1504836e5881ee8a0f776b770dcc8238dce37e8376e5c4301
!! source digest: sha256:310ce4e3f5919e5be643c54f11481d09bb8fc79cab65f08ac969ef3bf9d799fe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

View File

@@ -3,7 +3,7 @@
{
"name": "RMA (Return Merchandise Authorization)",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Introduces the return merchandise authorization (RMA) process in odoo",

View File

@@ -235,8 +235,6 @@ class RmaOrderLine(models.Model):
delivery_address_id = fields.Many2one(
comodel_name="res.partner",
string="Partner delivery address",
readonly=True,
states={"draft": [("readonly", False)]},
help="This address will be used to deliver repaired or replacement "
"products.",
)
@@ -250,8 +248,6 @@ class RmaOrderLine(models.Model):
string="Reference",
required=True,
default="/",
readonly=True,
states={"draft": [("readonly", False)]},
help="Add here the supplier RMA #. Otherwise an internal code is" " assigned.",
copy=False,
)
@@ -259,8 +255,6 @@ class RmaOrderLine(models.Model):
conditions = fields.Html(string="Terms and conditions")
origin = fields.Char(
string="Source Document",
readonly=True,
states={"draft": [("readonly", False)]},
help="Reference of the document that produced this rma.",
)
date_rma = fields.Datetime(
@@ -298,8 +292,6 @@ class RmaOrderLine(models.Model):
required=True,
store=True,
tracking=True,
readonly=True,
states={"draft": [("readonly", False)]},
)
sequence = fields.Integer(
default=10, help="Gives the sequence of this line when displaying the rma."
@@ -308,38 +300,28 @@ class RmaOrderLine(models.Model):
comodel_name="product.product",
ondelete="restrict",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
)
product_tracking = fields.Selection(related="product_id.tracking")
lot_id = fields.Many2one(
comodel_name="stock.lot",
string="Lot/Serial Number",
readonly=True,
states={"draft": [("readonly", False)]},
)
product_qty = fields.Float(
string="Return Qty",
copy=False,
default=1.0,
digits="Product Unit of Measure",
readonly=True,
states={"draft": [("readonly", False)]},
)
uom_id = fields.Many2one(
comodel_name="uom.uom",
string="Unit of Measure",
required=True,
readonly=True,
compute="_compute_uom_id",
precompute=True,
store=True,
states={"draft": [("readonly", False)]},
)
price_unit = fields.Monetary(
string="Unit cost",
readonly=True,
states={"draft": [("readonly", False)]},
help="Unit cost of the items under RMA",
)
in_shipment_count = fields.Integer(
@@ -355,8 +337,6 @@ class RmaOrderLine(models.Model):
comodel_name="stock.move",
string="Originating Stock Move",
copy=False,
readonly=True,
states={"draft": [("readonly", False)]},
)
currency_id = fields.Many2one(
"res.currency",
@@ -375,13 +355,9 @@ class RmaOrderLine(models.Model):
)
customer_to_supplier = fields.Boolean(
"The customer will send to the supplier",
readonly=True,
states={"draft": [("readonly", False)]},
)
supplier_to_customer = fields.Boolean(
"The supplier will send to the customer",
readonly=True,
states={"draft": [("readonly", False)]},
)
receipt_policy = fields.Selection(
[
@@ -409,45 +385,35 @@ class RmaOrderLine(models.Model):
string="Inbound Route",
required=True,
domain=[("rma_selectable", "=", True)],
readonly=True,
compute="_compute_in_route_id",
precompute=True,
store=True,
states={"draft": [("readonly", False)]},
)
out_route_id = fields.Many2one(
"stock.route",
string="Outbound Route",
required=True,
domain=[("rma_selectable", "=", True)],
readonly=True,
compute="_compute_out_route_id",
precompute=True,
store=True,
states={"draft": [("readonly", False)]},
)
in_warehouse_id = fields.Many2one(
comodel_name="stock.warehouse",
string="Inbound Warehouse",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self._default_warehouse_id(),
)
out_warehouse_id = fields.Many2one(
comodel_name="stock.warehouse",
string="Outbound Warehouse",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self._default_warehouse_id(),
)
location_id = fields.Many2one(
comodel_name="stock.location",
string="Send To This Company Location",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self._default_location_id(),
)
customer_rma_id = fields.Many2one(
@@ -459,15 +425,11 @@ class RmaOrderLine(models.Model):
)
supplier_address_id = fields.Many2one(
comodel_name="res.partner",
readonly=True,
states={"draft": [("readonly", False)]},
string="Supplier Address",
help="Address of the supplier in case of Customer RMA operation " "dropship.",
)
customer_address_id = fields.Many2one(
comodel_name="res.partner",
readonly=True,
states={"draft": [("readonly", False)]},
string="Customer Address",
help="Address of the customer in case of Supplier RMA operation " "dropship.",
)
@@ -526,9 +488,7 @@ class RmaOrderLine(models.Model):
compute="_compute_qty_supplier_rma",
store=True,
)
under_warranty = fields.Boolean(
string="Under Warranty?", readonly=True, states={"draft": [("readonly", False)]}
)
under_warranty = fields.Boolean(string="Under Warranty?")
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
if not self.type:

View File

@@ -77,8 +77,8 @@ class StockMove(models.Model):
def _update_reserved_quantity(
self,
need,
available_quantity,
location_id,
quant_ids=None,
lot_id=None,
package_id=None,
owner_id=None,
@@ -93,8 +93,8 @@ class StockMove(models.Model):
lot_id = self.rma_line_id.lot_id
return super()._update_reserved_quantity(
need,
available_quantity,
location_id,
quant_ids=quant_ids,
lot_id=lot_id,
package_id=package_id,
owner_id=owner_id,

View File

@@ -91,7 +91,7 @@ class StockWarehouse(models.Model):
self.mapped("rma_customer_out_pull_id").unlink()
self.mapped("rma_supplier_in_pull_id").unlink()
self.mapped("rma_supplier_out_pull_id").unlink()
return super(StockWarehouse, self).write(vals)
return super().write(vals)
def _create_rma_picking_types(self):
picking_type_obj = self.env["stock.picking.type"]

View File

@@ -34,7 +34,7 @@
id="stock_report_delivery_has_serial_move_line"
inherit_id="stock.stock_report_delivery_has_serial_move_line"
>
<xpath expr="//td[@name='move_line_lot_qty_done']" position="before">
<xpath expr="//td[@name='move_line_lot_quantity']" position="before">
<td t-if="sml_has_rma">
<span t-field="move_line.move_id.rma_line_id" />
</td>
@@ -45,7 +45,7 @@
id="stock_report_delivery_aggregated_move_lines"
inherit_id="stock.stock_report_delivery_aggregated_move_lines"
>
<xpath expr="//td[@name='move_line_aggregated_qty_done']" position="before">
<xpath expr="//td[@name='move_line_aggregated_quantity']" position="before">
<td t-if="sml_has_rma">
<!-- TODO: To be implemented.
It will require de extension _get_aggregated_product_quantities

View File

@@ -366,7 +366,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:51ec7a60674dede1504836e5881ee8a0f776b770dcc8238dce37e8376e5c4301
!! source digest: sha256:310ce4e3f5919e5be643c54f11481d09bb8fc79cab65f08ac969ef3bf9d799fe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/ForgeFlow/stock-rma/tree/17.0/rma"><img alt="ForgeFlow/stock-rma" src="https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github" /></a></p>
<p>A Return Merchandise Authorization (RMA), is a part of the process of

View File

@@ -10,7 +10,7 @@ class TestRma(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestRma, cls).setUpClass()
super().setUpClass()
# models
cls.rma_make_picking = cls.env["rma_make_picking.wizard"]
cls.make_supplier_rma = cls.env["rma.order.line.make.supplier.rma"]
@@ -109,7 +109,8 @@ class TestRma(common.TransactionCase):
picking = cls.env["stock.picking"].browse(res["res_id"])
picking.action_assign()
for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
mv.quantity = mv.product_uom_qty
mv.picked = True
picking._action_done()
return picking
@@ -128,7 +129,8 @@ class TestRma(common.TransactionCase):
picking = cls.env["stock.picking"].browse(res["res_id"])
picking.action_assign()
for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
mv.quantity = mv.product_uom_qty
mv.picked = True
picking._action_done()
return picking
@@ -168,9 +170,8 @@ class TestRma(common.TransactionCase):
picking.action_confirm()
picking.action_assign()
for ml in picking.move_ids:
ml.filtered(
lambda m: m.state != "waiting"
).quantity_done = ml.product_uom_qty
ml.filtered(lambda m: m.state != "waiting").quantity = ml.product_uom_qty
ml.filtered(lambda m: m.state != "waiting").picked = True
picking.button_validate()
@classmethod
@@ -443,38 +444,39 @@ class TestRma(common.TransactionCase):
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty to receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_incoming,
lines.filtered(lambda x: x.product_id == self.product_1).qty_incoming,
3,
"Wrong qty incoming",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_receive,
5,
"Wrong qty to receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_incoming,
lines.filtered(lambda x: x.product_id == self.product_2).qty_incoming,
5,
"Wrong qty incoming",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_receive,
2,
"Wrong qty to receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_incoming,
lines.filtered(lambda x: x.product_id == self.product_3).qty_incoming,
2,
"Wrong qty incoming",
)
picking.action_assign()
for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
mv.quantity = mv.product_uom_qty
mv.picked = True
picking._action_done()
lines = self.rma_customer_id.rma_line_ids
self.assertEqual(
@@ -491,32 +493,32 @@ class TestRma(common.TransactionCase):
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
lines.filtered(lambda x: x.product_id == self.product_1).qty_received,
3,
"Wrong qty received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
lines.filtered(lambda x: x.product_id == self.product_2).qty_received,
5,
"Wrong qty received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
lines.filtered(lambda x: x.product_id == self.product_3).qty_received,
2,
"Wrong qty received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty to_deliver",
)
@@ -562,38 +564,39 @@ class TestRma(common.TransactionCase):
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_outgoing,
lines.filtered(lambda x: x.product_id == self.product_1).qty_outgoing,
3,
"Wrong qty outgoing",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_outgoing,
lines.filtered(lambda x: x.product_id == self.product_2).qty_outgoing,
5,
"Wrong qty outgoing",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_outgoing,
lines.filtered(lambda x: x.product_id == self.product_3).qty_outgoing,
2,
"Wrong qty outgoing",
)
picking.action_assign()
for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
mv.quantity = mv.product_uom_qty
mv.picked = True
picking._action_done()
lines = self.rma_customer_id.rma_line_ids
self.assertEqual(
@@ -607,32 +610,32 @@ class TestRma(common.TransactionCase):
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
lines.filtered(lambda x: x.product_id == self.product_1).qty_received,
3,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_1).qty_delivered,
3,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
lines.filtered(lambda x: x.product_id == self.product_2).qty_received,
5,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_2).qty_delivered,
5,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
lines.filtered(lambda x: x.product_id == self.product_3).qty_received,
2,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_3).qty_delivered,
2,
"Wrong qty_delivered",
)
@@ -702,17 +705,17 @@ class TestRma(common.TransactionCase):
self.assertEqual(list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered")
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty_to_deliver",
)
@@ -720,21 +723,21 @@ class TestRma(common.TransactionCase):
lines.env.invalidate_all()
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_1
lambda x: x.product_id == self.product_1
).qty_in_supplier_rma,
3,
"Wrong qty_in_supplier_rma",
)
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_2
lambda x: x.product_id == self.product_2
).qty_in_supplier_rma,
5,
"Wrong qty_in_supplier_rma",
)
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_3
lambda x: x.product_id == self.product_3
).qty_in_supplier_rma,
2,
"Wrong qty_in_supplier_rma",
@@ -791,32 +794,32 @@ class TestRma(common.TransactionCase):
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_receive,
5,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_receive,
2,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty_to_deliver",
)
@@ -825,7 +828,8 @@ class TestRma(common.TransactionCase):
)
picking.action_assign()
for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
mv.quantity = mv.product_uom_qty
mv.picked = True
picking._action_done()
self.assertEqual(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
@@ -839,37 +843,37 @@ class TestRma(common.TransactionCase):
self.assertEqual(list(set(lines.mapped("qty_outgoing"))), [0], "qty_outgoing")
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_1).qty_delivered,
3,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
lines.filtered(lambda x: x.product_id == self.product_1).qty_received,
0,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_2).qty_delivered,
5,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
lines.filtered(lambda x: x.product_id == self.product_2).qty_received,
0,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_3).qty_delivered,
2,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
lines.filtered(lambda x: x.product_id == self.product_3).qty_received,
0,
"Wrong qty_received",
)
@@ -911,24 +915,25 @@ class TestRma(common.TransactionCase):
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_2).qty_to_receive,
5,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
lines.filtered(lambda x: x.product_id == self.product_3).qty_to_receive,
2,
"Wrong qty_to_receive",
)
picking_in.action_confirm()
picking_in.action_assign()
for mv in picking_in.move_line_ids:
mv.qty_done = mv.reserved_uom_qty
mv.quantity = mv.quantity_product_uom
mv.picked = True
picking_in._action_done()
self.assertEqual(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
@@ -942,32 +947,32 @@ class TestRma(common.TransactionCase):
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_1).qty_delivered,
3,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
lines.filtered(lambda x: x.product_id == self.product_1).qty_received,
3,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_2).qty_delivered,
5,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
lines.filtered(lambda x: x.product_id == self.product_2).qty_received,
5,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered,
lines.filtered(lambda x: x.product_id == self.product_3).qty_delivered,
2,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
lines.filtered(lambda x: x.product_id == self.product_3).qty_received,
2,
"Wrong qty_received",
)

View File

@@ -7,7 +7,7 @@
<field name="priority" eval="10" />
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<xpath expr="//form" position="inside">
<div
class="app_settings_block"
data-string="RMA"
@@ -27,7 +27,7 @@
<div class="o_setting_right_pane">
<label for="group_rma_delivery_address" />
<div class="text-muted">
Display 3 fields on rma: partner, invoice address, delivery address.
Display 3 fields on rma: partner, invoice address, delivery address
</div>
</div>
</div>

View File

@@ -24,7 +24,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<div class="oe_button_box" name="button_box" />
<group colspan="4" col="2">
@@ -51,7 +51,7 @@
/>
<field
name="customer_to_supplier"
attrs="{'invisible':[('type', '=', 'supplier')]}"
invisible="type == 'supplier'"
/>
</group>
<group name="outbound" string="Outbound">
@@ -59,7 +59,7 @@
<field name="out_warehouse_id" />
<field
name="supplier_to_customer"
attrs="{'invisible':[('type', '=', 'customer')]}"
invisible="type == 'customer'"
/>
</group>
</group>

View File

@@ -61,7 +61,7 @@
name="action_rma_to_approve"
type="object"
string="Request Approval"
attrs="{'invisible':[('state', '!=', 'draft')]}"
invisible="state != 'draft'"
class="oe_highlight"
groups="rma.group_rma_customer_user"
/>
@@ -69,14 +69,14 @@
name="action_rma_draft"
type="object"
string="Back to Draft"
attrs="{'invisible':[('state', '=', 'draft')]}"
invisible="state == 'draft'"
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
/>
<button
name="action_rma_approve"
type="object"
string="Approve"
attrs="{'invisible':[('state', '!=', 'to_approve')]}"
invisible="state != 'to_approve'"
class="oe_highlight"
groups="rma.group_rma_manager"
/>
@@ -84,21 +84,21 @@
name="action_rma_approve"
type="object"
string="Back to Approved"
attrs="{'invisible':[('state', '!=', 'done')]}"
invisible="state != 'done'"
groups="rma.group_rma_customer_user"
/>
<button
name="action_rma_done"
type="object"
string="Done"
attrs="{'invisible':[('state', 'in', ('done', 'draft', 'canceled'))]}"
invisible="state in ('done', 'draft', 'canceled')"
groups="rma.group_rma_customer_user"
/>
<button
name="action_rma_cancel"
type="object"
string="Cancel"
attrs="{'invisible':[('state', 'in', ('done', 'canceled'))]}"
invisible="state in ('done', 'canceled')"
groups="rma.group_rma_customer_user"
/>
<field
@@ -115,7 +115,7 @@
name="action_view_in_shipments"
class="oe_stat_button"
icon="fa-truck"
attrs="{'invisible': [('in_shipment_count', '=', 0)]}"
invisible="in_shipment_count == 0"
groups="stock.group_stock_user"
>
<field
@@ -129,7 +129,7 @@
name="action_view_out_shipments"
class="oe_stat_button"
icon="fa-truck"
attrs="{'invisible': [('out_shipment_count', '=', 0)]}"
invisible="out_shipment_count == 0"
groups="stock.group_stock_user"
>
<field
@@ -150,7 +150,7 @@
class="oe_stat_button"
icon="fa-link"
groups="stock.group_stock_user"
attrs="{'invisible': [('rma_line_count', '=', 0)]}"
invisible="rma_line_count == 0"
>
<field
name="rma_line_count"
@@ -163,7 +163,7 @@
<h1>
<field
name="name"
readonly="1"
readonly="state not in ['draft']"
invisible="context.get('hide_title',False)"
/>
</h1>
@@ -174,6 +174,7 @@
name="partner_id"
context="{'res_partner_search_mode': 'customer'}"
string="Customer"
readonly="state not in ['draft']"
/>
<field
name="delivery_address_id"
@@ -182,6 +183,7 @@
context="{'show_address': 1}"
options="{'always_reload': 1}"
groups='rma.group_rma_delivery_invoice_address'
readonly="state not in ['draft']"
/>
</group>
<group>
@@ -195,22 +197,39 @@
</group>
<group>
<group name="product" string="Product">
<field name="product_id" />
<field
name="product_id"
readonly="state not in ['draft']"
/>
<newline />
<field name="product_tracking" invisible="1" />
<field
name="lot_id"
groups="stock.group_production_lot"
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"
required="product_tracking in ('serial', 'lot')"
context="{'default_product_id': product_id,}"
domain="[('product_id', '=', product_id)]"
readonly="state not in ['draft']"
/>
<field
name="under_warranty"
readonly="state not in ['draft']"
/>
<field name="under_warranty" />
</group>
<group name="product_qty" string="Quantity">
<field name="product_qty" />
<field name="uom_id" groups="uom.group_uom" />
<field name="price_unit" />
<field
name="product_qty"
readonly="state not in ['draft']"
/>
<field
name="uom_id"
groups="uom.group_uom"
readonly="state not in ['draft']"
/>
<field
name="price_unit"
readonly="state not in ['draft']"
/>
</group>
</group>
<group name="main_info" string="Origin">
@@ -220,6 +239,7 @@
domain="[('picking_id.partner_id', '=', partner_id),
('location_dest_id.usage', '=', 'customer'),
('state', '=', 'done')]"
readonly="state not in ['draft']"
/>
</group>
<group>
@@ -240,7 +260,7 @@
<group name="quantities" col="4" string="Quantities">
<group
name="receive"
attrs="{'invisible': [('receipt_policy', '=', 'no')]}"
invisible="receipt_policy == 'no'"
>
<field name="qty_to_receive" />
<field name="qty_incoming" />
@@ -248,7 +268,7 @@
</group>
<group
name="deliver"
attrs="{'invisible': [('delivery_policy', '=', 'no')]}"
invisible="delivery_policy == 'no'"
>
<field name="qty_to_deliver" />
<field name="qty_outgoing" />
@@ -256,7 +276,7 @@
</group>
<group
name="supplier_rma"
attrs="{'invisible':['|', ('type', '!=', 'customer'), ('customer_to_supplier','=',False)]}"
invisible="type != 'customer' or not customer_to_supplier"
>
<field name="qty_to_supplier_rma" />
<field name="qty_in_supplier_rma" />
@@ -265,50 +285,63 @@
</page>
<page name="route" string="Routes">
<group name="inbound" string="Inbound">
<field name="in_warehouse_id" />
<field
name="in_warehouse_id"
readonly="state not in ['draft']"
/>
<field
name="location_id"
domain="[('usage', '=', 'internal')]"
readonly="state not in ['draft']"
/>
<field
name="in_route_id"
groups="stock.group_adv_location"
readonly="state not in ['draft']"
/>
<field
name="customer_to_supplier"
attrs="{'invisible':[('type', '!=', 'customer')]}"
invisible="type != 'customer'"
readonly="state not in ['draft']"
/>
<field
name="supplier_address_id"
context="{'show_address': 1}"
options="{'always_reload': 1}"
attrs="{'required':[('customer_to_supplier', '=', True)],
'invisible':[('customer_to_supplier', '=', False)]}"
required="customer_to_supplier == True"
invisible="customer_to_supplier == False"
readonly="state not in ['draft']"
/>
</group>
<group name="outbound" string="Outbound">
<field name="out_warehouse_id" />
<field
name="out_warehouse_id"
readonly="state not in ['draft']"
/>
<field
name="out_route_id"
groups="stock.group_adv_location"
readonly="state not in ['draft']"
/>
<field
name="supplier_to_customer"
attrs="{'invisible':[('type', '!=', 'supplier')]}"
invisible="type != 'supplier'"
readonly="state not in ['draft']"
/>
<field
name="customer_address_id"
context="{'show_address': 1}"
options="{'always_reload': 1}"
attrs="{'required':[('supplier_to_customer', '=', True)],
'invisible':[('supplier_to_customer', '=', False)]}"
required="supplier_to_customer == True"
invisible="supplier_to_customer == False"
readonly="state not in ['draft']"
/>
</group>
</page>
<page
name="stock"
string="Stock Moves"
attrs="{'invisible': [('move_ids', '=', [])]}"
invisible="not move_ids"
>
<field name="move_ids" nolabel="1" readonly="1" />
</page>

View File

@@ -38,7 +38,7 @@
name="action_rma_to_approve"
type="object"
string="Request Approval"
attrs="{'invisible':[('state', '!=', 'draft')]}"
invisible="state != 'draft'"
class="oe_highlight"
groups="rma.group_rma_customer_user"
/>
@@ -46,14 +46,14 @@
name="action_rma_draft"
type="object"
string="Back to Draft"
attrs="{'invisible':[('state', '=', 'draft')]}"
invisible="state == 'draft'"
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
/>
<button
name="action_rma_approve"
type="object"
string="Approve"
attrs="{'invisible':[('state', '!=', 'to_approve')]}"
invisible="state != 'to_approve'"
class="oe_highlight"
groups="rma.group_rma_manager"
/>
@@ -61,21 +61,21 @@
name="action_rma_approve"
type="object"
string="Back to Approved"
attrs="{'invisible':[('state', '!=', 'done')]}"
invisible="state != 'done'"
groups="rma.group_rma_customer_user"
/>
<button
name="action_rma_done"
type="object"
string="Done"
attrs="{'invisible':[('state', 'in', ('done', 'draft', 'cancel'))]}"
invisible="state in ('done', 'draft', 'cancel')"
groups="rma.group_rma_customer_user"
/>
<button
name="action_rma_cancel"
type="object"
string="Cancel"
attrs="{'invisible':[('state', 'in', ('done', 'cancel'))]}"
invisible="state in ('done', 'cancel')"
groups="rma.group_rma_customer_user"
/>
<field
@@ -126,7 +126,7 @@
type="object"
name="action_view_supplier_lines"
class="oe_stat_button"
attrs="{'invisible':[('supplier_line_count', '=', 0)]}"
invisible="supplier_line_count == 0"
icon="fa-list"
groups="rma.group_rma_supplier_user"
>
@@ -150,21 +150,12 @@
context="{'res_partner_search_mode': 'customer'}"
string="Customer"
/>
<field
name="reference"
attrs="{'invisible':[('type', '!=', 'supplier')]}"
/>
<field
name="date_rma"
attrs="{'readonly':[('state', '!=', 'draft')]}"
/>
<field name="reference" invisible="type != 'supplier'" />
<field name="date_rma" readonly="state != 'draft'" />
</group>
<group name="contact">
<field name="requested_by" readonly="1" />
<field
name="assigned_to"
attrs="{'readonly':[('state', '!=', 'draft')]}"
/>
<field name="assigned_to" readonly="state != 'draft'" />
<field name="company_id" groups="base.group_multi_company" />
</group>
</group>
@@ -174,41 +165,32 @@
name="operation_default_id"
domain="[('type','=','customer')]"
/>
<field
name="in_warehouse_id"
attrs="{'readonly':[('state', '!=', 'draft')]}"
/>
<field
name="in_route_id"
attrs="{'readonly':[('state', '!=', 'draft')]}"
/>
<field name="in_warehouse_id" readonly="state != 'draft'" />
<field name="in_route_id" readonly="state != 'draft'" />
<field
name="out_warehouse_id"
invisible="1"
attrs="{'readonly':[('state', '!=', 'draft')]}"
/>
<field
name="location_id"
attrs="{'readonly':[('state', '!=', 'draft')]}"
readonly="state != 'draft'"
/>
<field name="location_id" readonly="state != 'draft'" />
<field
name="out_route_id"
invisible="1"
attrs="{'readonly':[('state', '!=', 'draft')]}"
readonly="state != 'draft'"
/>
<field
name="customer_to_supplier"
attrs="{'readonly':[('state', '!=', 'draft')],
'invisible':[('type', '!=', 'customer')]}"
readonly="state != 'draft'"
invisible="type != 'customer'"
/>
<field name="state" invisible="1" />
<field
name="supplier_address_id"
context="{'show_address': 1}"
options="{'always_reload': 1}"
attrs="{'required':[('customer_to_supplier', '=', True)],
'invisible':[('customer_to_supplier', '=', False)],
'readonly':[('state', '!=', 'draft')]}"
required="customer_to_supplier == True"
invisible="customer_to_supplier == False"
readonly="state != 'draft'"
/>
</group>
</group>
@@ -228,7 +210,7 @@
<page string="RMA Lines" name="lines">
<field
name="rma_line_ids"
context="{'default_rma_id': active_id,
context="{'default_rma_id': id,
'default_partner_id': partner_id,
'hide_title': True}"
>
@@ -299,24 +281,21 @@
</field>
<group name="inbound_route" position="after">
<group name="outbound_route" string="Outbound">
<field
name="supplier_to_customer"
attrs="{'readonly':[('state', '!=', 'draft')]}"
/>
<field name="supplier_to_customer" readonly="state != 'draft'" />
<field
name="customer_address_id"
context="{'show_address': 1}"
options="{'always_reload': 1}"
attrs="{'required':[('supplier_to_customer', '=', True)],
'invisible':[('supplier_to_customer', '=', False)],
'readonly':[('state', '!=', 'draft')]}"
required="supplier_to_customer == True"
invisible="supplier_to_customer == False"
readonly="state != 'draft'"
/>
</group>
</group>
<field name="rma_line_ids" position="attributes">
<attribute name="context">{
'form_view_ref':'rma.view_rma_line_supplier_form',
'default_rma_id': active_id,
'default_rma_id': id,
'default_partner_id': partner_id,
'supplier': 1,
'hide_title': True}

View File

@@ -55,7 +55,7 @@
name="%(action_rma_add_serial_wiz_customer)d"
string="Add Lot/Serial Numbers"
type="action"
attrs="{'invisible':[('type', '!=', 'customer')]}"
invisible="type != 'customer'"
/>
</xpath>
</field>
@@ -93,7 +93,7 @@
name="%(action_rma_add_serial_wiz_supplier)d"
string="Add Lot/Serial numbers"
type="action"
attrs="{'invisible':[('type', '!=', 'supplier')]}"
invisible="type != 'supplier'"
/>
</xpath>
</field>

View File

@@ -11,7 +11,7 @@ class RmaAddStockMove(models.TransientModel):
@api.model
def default_get(self, fields_list):
res = super(RmaAddStockMove, self).default_get(fields_list)
res = super().default_get(fields_list)
rma_obj = self.env["rma.order"]
rma_id = self.env.context["active_ids"] or []
active_model = self.env.context["active_model"]
@@ -192,8 +192,8 @@ class RmaAddStockMove(models.TransientModel):
# Ensure that configuration on the operation is applied (like
# policies).
# TODO MIG: in v16 the usage of such onchange can be removed in
# favor of (pre)computed stored editable fields for all policies
# and configuration in the RMA operation.
# favor of (pre)computed stored editable fields for all
# policies and configuration in the RMA operation.
rec._onchange_operation_id()
rec.price_unit = rec._get_price_unit()
return {"type": "ir.actions.act_window_close"}

View File

@@ -34,23 +34,20 @@
</field>
<field name="show_lot_filter" invisible="1" />
<field name="lot_domain_ids" widget="many2many_tags" invisible="1" />
<div
class="oe_grey"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
>
<div class="oe_grey" invisible="show_lot_filter == False">
The creation of the RMA Lines will be separated according to the lots or serials selected
</div>
<div class="o_row">
<label
for="lot_ids"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
invisible="show_lot_filter == False"
string="Selected Lot/Serial Numbers"
/>
<field
name="lot_ids"
widget="many2many_tags"
domain="[('id', 'in', lot_domain_ids)]"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
invisible="show_lot_filter == False"
options="{'no_create': True}"
/>
<button
@@ -58,7 +55,7 @@
type="object"
string="Select all"
class="oe_inline"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
invisible="show_lot_filter == False"
/>
</div>
<footer>
@@ -101,7 +98,7 @@
name="%(action_rma_add_stock_move_customer)d"
string="Add From Stock Move"
type="action"
attrs="{'invisible':[('type', '!=', 'customer')]}"
invisible="type != 'customer'"
/>
</xpath>
</field>
@@ -125,14 +122,14 @@
<div class="o_row">
<label
for="lot_ids"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
invisible="show_lot_filter == False"
string="Selected Lot/Serial Numbers"
/>
<field
name="lot_ids"
widget="many2many_tags"
domain="[('id', 'in', lot_domain_ids)]"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
invisible="show_lot_filter == False"
options="{'no_create': True}"
/>
<button
@@ -140,7 +137,7 @@
type="object"
string="Select all"
class="oe_inline"
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
invisible="show_lot_filter == False"
/>
</div>
<footer>
@@ -182,7 +179,7 @@
name="%(action_rma_add_stock_move_supplier)d"
string="Add From Stock Move"
type="action"
attrs="{'invisible':[('type', '!=', 'supplier')]}"
invisible="type != 'supplier'"
/>
</xpath>
</field>

View File

@@ -33,7 +33,7 @@ class RmaMakePicking(models.TransientModel):
supplier.
"""
context = self._context.copy()
res = super(RmaMakePicking, self).default_get(fields_list)
res = super().default_get(fields_list)
rma_line_obj = self.env["rma.order.line"]
rma_line_ids = self.env.context["active_ids"] or []
active_model = self.env.context["active_model"]
@@ -237,11 +237,13 @@ class RmaMakePicking(models.TransientModel):
elif move.product_id.tracking == "lot":
if picking_type == "incoming":
qty = self.item_ids.filtered(
lambda x: x.line_id.id == move.rma_line_id.id
lambda x, move_rma_line_id=move.rma_line_id: x.line_id.id
== move_rma_line_id.id
).qty_to_receive
else:
qty = self.item_ids.filtered(
lambda x: x.line_id.id == move.rma_line_id.id
lambda x, move_rma_line_id=move.rma_line_id: x.line_id.id
== move_rma_line_id.id
).qty_to_deliver
move_line_data = move._prepare_move_line_vals()
move_line_data.update(

View File

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

View File

@@ -50,7 +50,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
@api.model
def default_get(self, fields_list):
res = super(RmaLineMakeSupplierRma, self).default_get(fields_list)
res = super().default_get(fields_list)
rma_line_obj = self.env["rma.order.line"]
rma_line_ids = self.env.context["active_ids"] or []
active_model = self.env.context["active_model"]

View File

@@ -68,7 +68,7 @@
<button
name="%(action_rma_order_line_make_supplier_rma)d"
string="Create Supplier RMA"
attrs="{'invisible':['|', ('type', '!=', 'customer'), ('state', '!=', 'approved')]}"
invisible="type != 'customer' or state != 'approved'"
type="action"
/>
</header>