Skip to content

Commit

Permalink
[MIG] rma_scrap: migration to v17
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosVForgeFlow authored and AaronHForgeFlow committed Aug 22, 2024
1 parent 97641a8 commit 8065e91
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion rma_scrap/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "RMA Scrap",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Allows to scrap the received/ordered products in odoo",
Expand Down
2 changes: 1 addition & 1 deletion rma_scrap/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _compute_scrap_count(self):

@api.onchange("operation_id")
def _onchange_operation_id(self):
res = super(RmaOrderLine, self)._onchange_operation_id()
res = super()._onchange_operation_id()
if self.operation_id:
self.scrap_policy = self.operation_id.scrap_policy or "no"
return res
Expand Down
8 changes: 4 additions & 4 deletions rma_scrap/models/stock_scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class StockScrap(models.Model):
)

def do_scrap(self):
res = super(StockScrap, self).do_scrap()
res = super().do_scrap()
if self.is_rma_scrap:
self.move_id.is_rma_scrap = True
self.rma_line_id.move_ids |= self.move_id
self.move_ids.is_rma_scrap = True
self.rma_line_id.move_ids |= self.move_ids
return res

def _prepare_move_values(self):
res = super(StockScrap, self)._prepare_move_values()
res = super()._prepare_move_values()
res["rma_line_id"] = self.rma_line_id.id
return res

Expand Down
10 changes: 5 additions & 5 deletions rma_scrap/tests/test_rma_scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class TestRmaScrap(common.SingleTransactionCase):
@classmethod
def setUpClass(cls):
super(TestRmaScrap, cls).setUpClass()
super().setUpClass()

cls.rma_obj = cls.env["rma.order"]
cls.rma_line_obj = cls.env["rma.order.line"]
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_01_rma_scrap_received(self):

action_picking = wizard.action_create_picking()
picking = self.env["stock.picking"].browse([action_picking["res_id"]])
picking.move_line_ids[0].qty_done = rma.qty_to_receive
picking.move_line_ids[0].quantity = rma.qty_to_receive

picking.button_validate()
rma._compute_qty_to_scrap()
Expand Down Expand Up @@ -137,9 +137,9 @@ def test_01_rma_scrap_received(self):
action = wizard.action_create_scrap()
scrap = self.env["stock.scrap"].browse([action["res_id"]])
self.assertEqual(scrap.location_id.id, self.stock_rma_location.id)
self.assertEqual(scrap.move_id.id, False)
self.assertEqual(scrap.move_ids.id, False)
scrap.action_validate()
move = scrap.move_id
move = scrap.move_ids
self.assertEqual(move.product_id.id, self.product_1.id)
self.assertFalse(rma.qty_to_scrap)
self.assertEqual(rma.qty_scrap, 1.00)
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_02_rma_scrap_ordered(self):
action = wizard.action_create_scrap()
scrap = self.env["stock.scrap"].browse([action["res_id"]])
self.assertEqual(scrap.location_id.id, self.stock_rma_location.id)
self.assertEqual(scrap.move_id.id, False)
self.assertEqual(scrap.move_ids.id, False)
self.assertEqual(rma.qty_in_scrap, 1.00)
res = scrap.action_validate()
scrap.do_scrap()
Expand Down
2 changes: 1 addition & 1 deletion rma_scrap/views/rma_order_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class="oe_stat_button"
icon="fa-truck"
groups="stock.group_stock_user"
attrs="{'invisible':['|', ('scrap_count', '=', 0), ('state', '=', 'draft')]}"
invisible="scrap_count == 0 or state == 'draft'"
>
<field name="scrap_count" widget="statinfo" string="Scraps" />
</button>
Expand Down
2 changes: 1 addition & 1 deletion rma_scrap/views/rma_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class="oe_stat_button"
icon="fa-truck"
groups="stock.group_stock_user"
attrs="{'invisible': [('scrap_count', '=', 0)]}"
invisible="scrap_count == 0"
>
<field name="scrap_count" widget="statinfo" string="Scraps" />
</button>
Expand Down
2 changes: 1 addition & 1 deletion rma_scrap/views/stock_scrap_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
icon="fa-eject"
string="RMA Line"
groups="stock.group_stock_user"
attrs="{'invisible': [('rma_line_id', '=', False)]}"
invisible="rma_line_id == False"
>
</button>
<field name="rma_line_id" invisible="1" />
Expand Down
5 changes: 3 additions & 2 deletions rma_scrap/wizards/rma_make_scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _prepare_item(self, line):
@api.model
def default_get(self, fields_list):
context = self._context.copy()
res = super(RmaMakeScrap, 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"]
Expand Down Expand Up @@ -107,7 +107,8 @@ class RmaMakeScrapItem(models.TransientModel):
"stock.location",
string="Source Location",
required=True,
domain="[('usage', '=', 'internal'), ('company_id', 'in', [company_id, False])]",
domain="[('usage', '=', 'internal'),"
"('company_id', 'in', [company_id, False])]",
)
scrap_location_id = fields.Many2one(
"stock.location",
Expand Down
4 changes: 2 additions & 2 deletions rma_scrap/wizards/rma_scrap_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
name="%(action_rma_scrap)d"
string="Scrap"
class="oe_highlight"
attrs="{'invisible':['|', ('qty_to_scrap', '=', 0), ('state', '!=', 'approved')]}"
invisible="qty_to_scrap == 0 or state != 'approved'"
type="action"
groups="stock.group_stock_user"
/>
<button
name="%(action_rma_scrap)d"
string="Scrap"
attrs="{'invisible':['|', ('qty_to_scrap', '!=', 0), ('state', '!=', 'approved')]}"
invisible="qty_to_scrap != 0 or state != 'approved'"
type="action"
groups="stock.group_stock_user"
/>
Expand Down

0 comments on commit 8065e91

Please sign in to comment.