diff --git a/rma_purchase/__manifest__.py b/rma_purchase/__manifest__.py
index 1e54be81c..8c7aa9dd2 100644
--- a/rma_purchase/__manifest__.py
+++ b/rma_purchase/__manifest__.py
@@ -2,7 +2,7 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
{
"name": "RMA Purchase",
- "version": "16.0.1.0.0",
+ "version": "17.0.1.0.0",
"category": "RMA",
"summary": "RMA from PO",
"license": "LGPL-3",
diff --git a/rma_purchase/models/account_move.py b/rma_purchase/models/account_move.py
index c173139fd..8b0230906 100644
--- a/rma_purchase/models/account_move.py
+++ b/rma_purchase/models/account_move.py
@@ -8,15 +8,15 @@ class AccountMove(models.Model):
_inherit = "account.move"
def _prepare_invoice_line_from_rma_line(self, line):
- data = super(AccountMove, self)._prepare_invoice_line_from_rma_line(line)
+ data = super()._prepare_invoice_line_from_rma_line(line)
if line.purchase_order_line_id:
- data["purchase_line_id"]: line.purchase_order_line_id.id
+ data["purchase_line_id"] = line.purchase_order_line_id.id
return data
def action_post(self):
- res = super(AccountMove, self).action_post()
+ res = super().action_post()
for move in self:
- rma_mls = move.line_ids.filtered(lambda l: l.rma_line_id)
+ rma_mls = move.line_ids.filtered(lambda x: x.rma_line_id)
if rma_mls:
# Try to reconcile the interim accounts for RMA lines
rmas = rma_mls.mapped("rma_line_id")
diff --git a/rma_purchase/models/purchase_order.py b/rma_purchase/models/purchase_order.py
index 4d81bc049..0ab65155f 100644
--- a/rma_purchase/models/purchase_order.py
+++ b/rma_purchase/models/purchase_order.py
@@ -10,7 +10,7 @@ class PurchaseOrder(models.Model):
@api.model
def new(self, vals, origin=None, ref=None):
"""Allows to propose a line based on the RMA information."""
- res = super(PurchaseOrder, self).new(vals)
+ res = super().new(vals)
rma_line_id = self.env.context.get("rma_line_id")
if rma_line_id:
rma_line = self.env["rma.order.line"].browse(rma_line_id)
diff --git a/rma_purchase/models/purchase_order_line.py b/rma_purchase/models/purchase_order_line.py
index 4962d8617..6459e1c1d 100644
--- a/rma_purchase/models/purchase_order_line.py
+++ b/rma_purchase/models/purchase_order_line.py
@@ -22,16 +22,14 @@ def name_search(self, name="", args=None, operator="ilike", limit=100):
(self._rec_name, operator, name),
("order_id.name", operator, name),
]
- return super(PurchaseOrderLine, self).name_search(
- name=name, args=args, operator=operator, limit=limit
- )
+ return super().name_search(name=name, args=args, operator=operator, limit=limit)
@api.model
def _name_search(
self, name="", args=None, operator="ilike", limit=100, name_get_uid=None
):
"""Typed text is cleared here for better extensibility."""
- return super(PurchaseOrderLine, self)._name_search(
+ return super()._name_search(
name="",
args=args,
operator=operator,
@@ -50,8 +48,7 @@ def name_get(self):
res.append(
(
purchase.id,
- "%s %s %s qty:%s"
- % (
+ "{} {} {} qty:{}".format(
purchase.order_id.name,
" ".join(
str(x)
@@ -68,11 +65,12 @@ def name_get(self):
res.append(super(PurchaseOrderLine, purchase).name_get()[0])
return res
else:
- return super(PurchaseOrderLine, self).name_get()
+ return super().name_get()
- @api.model
- def create(self, vals):
- rma_line_id = self.env.context.get("rma_line_id")
- if rma_line_id:
- vals["rma_line_id"] = rma_line_id
- return super(PurchaseOrderLine, self).create(vals)
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ rma_line_id = self.env.context.get("rma_line_id")
+ if rma_line_id:
+ vals["rma_line_id"] = rma_line_id
+ return super().create(vals_list)
diff --git a/rma_purchase/models/rma_order_line.py b/rma_purchase/models/rma_order_line.py
index a2e1aea4f..79edccf9b 100644
--- a/rma_purchase/models/rma_order_line.py
+++ b/rma_purchase/models/rma_order_line.py
@@ -43,8 +43,6 @@ def _compute_qty_purchase(self):
comodel_name="purchase.order.line",
string="Originating Purchase Line",
ondelete="restrict",
- readonly=True,
- states={"draft": [("readonly", False)]},
)
purchase_id = fields.Many2one(
string="Source Purchase Order",
@@ -92,7 +90,7 @@ def _compute_qty_purchase(self):
def _onchange_product_id(self):
"""Domain for purchase_order_line_id is computed here to make
it dynamic."""
- res = super(RmaOrderLine, self)._onchange_product_id()
+ res = super()._onchange_product_id()
if not res.get("domain"):
res["domain"] = {}
domain = [
@@ -107,7 +105,7 @@ def _onchange_product_id(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.purchase_policy = self.operation_id.purchase_policy or "no"
return res
@@ -202,7 +200,7 @@ def _check_purchase_partner(self):
)
def _remove_other_data_origin(self, exception):
- res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
+ res = super()._remove_other_data_origin(exception)
if not exception == "purchase_order_line_id":
self.purchase_order_line_id = False
return res
@@ -233,7 +231,7 @@ def _get_rma_purchased_qty(self):
def _get_price_unit(self):
self.ensure_one()
- price_unit = super(RmaOrderLine, self)._get_price_unit()
+ price_unit = super()._get_price_unit()
if self.purchase_order_line_id:
moves = self.purchase_order_line_id.move_ids
if moves:
diff --git a/rma_purchase/tests/test_rma_purchase.py b/rma_purchase/tests/test_rma_purchase.py
index 558d23894..8b4f546fa 100644
--- a/rma_purchase/tests/test_rma_purchase.py
+++ b/rma_purchase/tests/test_rma_purchase.py
@@ -7,7 +7,7 @@
class TestRmaPurchase(common.TransactionCase):
def setUp(self):
- super(TestRmaPurchase, self).setUp()
+ super().setUp()
self.rma_obj = self.env["rma.order"]
self.rma_line_obj = self.env["rma.order.line"]
diff --git a/rma_purchase/tests/test_rma_stock_account_purchase.py b/rma_purchase/tests/test_rma_stock_account_purchase.py
index c74842f2d..dec9dfc60 100644
--- a/rma_purchase/tests/test_rma_stock_account_purchase.py
+++ b/rma_purchase/tests/test_rma_stock_account_purchase.py
@@ -11,7 +11,7 @@
class TestRmaStockAccountPurchase(TestRmaStockAccount):
@classmethod
def setUpClass(cls):
- super(TestRmaStockAccountPurchase, cls).setUpClass()
+ super().setUpClass()
cls.pol_model = cls.env["purchase.order.line"]
cls.po_model = cls.env["purchase.order"]
cls.rma_operation_supplier_refund = cls.env.ref(
diff --git a/rma_purchase/views/rma_order_line_view.xml b/rma_purchase/views/rma_order_line_view.xml
index 6563cabd4..ab839d017 100644
--- a/rma_purchase/views/rma_order_line_view.xml
+++ b/rma_purchase/views/rma_order_line_view.xml
@@ -18,15 +18,15 @@
name="%(action_rma_order_line_make_purchase_order)d"
string="Create Purchase Order"
class="oe_highlight"
- attrs="{'invisible':['|', ('qty_to_purchase', '=', 0), ('state', '!=', 'approved')]}"
- context="{'rma_line_id': active_id, 'default_partner_id': partner_id}"
+ invisible="qty_to_purchase == 0 or state != 'approved'"
+ context="{'rma_line_id': id, 'default_partner_id': partner_id}"
type="action"
/>
@@ -37,7 +37,7 @@
class="oe_stat_button"
icon="fa-shopping-cart"
groups="purchase.group_purchase_user"
- attrs="{'invisible':[('purchase_count','=',0)]}"
+ invisible="purchase_count == 0"
>
-
+
@@ -66,10 +67,7 @@
-
+
diff --git a/rma_purchase/wizards/rma_add_purchase.py b/rma_purchase/wizards/rma_add_purchase.py
index 26aed30a7..dab2ab4fc 100644
--- a/rma_purchase/wizards/rma_add_purchase.py
+++ b/rma_purchase/wizards/rma_add_purchase.py
@@ -10,7 +10,7 @@ class RmaAddPurchase(models.TransientModel):
@api.model
def default_get(self, fields_list):
- res = super(RmaAddPurchase, 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"]
diff --git a/rma_purchase/wizards/rma_make_picking.py b/rma_purchase/wizards/rma_make_picking.py
index 36f16ba69..5f5e0a6ef 100644
--- a/rma_purchase/wizards/rma_make_picking.py
+++ b/rma_purchase/wizards/rma_make_picking.py
@@ -8,7 +8,7 @@ class RmaMakePicking(models.TransientModel):
_inherit = "rma_make_picking.wizard"
def _prepare_item(self, line):
- res = super(RmaMakePicking, self)._prepare_item(line)
+ res = super()._prepare_item(line)
res["purchase_order_line_id"] = line.purchase_order_line_id.id
return res
@@ -24,7 +24,7 @@ def _get_action(self, pickings, procurements):
result["domain"] = [("id", "in", po_list)]
return result
else:
- action = super(RmaMakePicking, self)._get_action(pickings, procurements)
+ action = super()._get_action(pickings, procurements)
return action
diff --git a/rma_purchase/wizards/rma_order_line_make_purchase_order.py b/rma_purchase/wizards/rma_order_line_make_purchase_order.py
index ce7020410..52169e78c 100644
--- a/rma_purchase/wizards/rma_order_line_make_purchase_order.py
+++ b/rma_purchase/wizards/rma_order_line_make_purchase_order.py
@@ -14,7 +14,7 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
partner_id = fields.Many2one(
comodel_name="res.partner",
required=False,
- readonly=1,
+ readonly=True,
)
item_ids = fields.One2many(
comodel_name="rma.order.line.make.purchase.order.item",
@@ -42,7 +42,7 @@ def _prepare_item(self, line):
@api.model
def default_get(self, fields_list):
- res = super(RmaLineMakePurchaseOrder, 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"]
diff --git a/rma_purchase/wizards/rma_refund.py b/rma_purchase/wizards/rma_refund.py
index d3ccb3920..92cb93d96 100644
--- a/rma_purchase/wizards/rma_refund.py
+++ b/rma_purchase/wizards/rma_refund.py
@@ -8,7 +8,7 @@ class RmaRefund(models.TransientModel):
_inherit = "rma.refund"
def _get_refund_price_unit(self, rma):
- price_unit = super(RmaRefund, self)._get_refund_price_unit(rma)
+ price_unit = super()._get_refund_price_unit(rma)
if rma.type == "supplier":
if rma.account_move_line_id:
price_unit = rma.account_move_line_id.price_unit
@@ -17,7 +17,7 @@ def _get_refund_price_unit(self, rma):
return price_unit
def _get_refund_currency(self, rma):
- currency = super(RmaRefund, self)._get_refund_currency(rma)
+ currency = super()._get_refund_currency(rma)
if rma.type == "supplier":
if rma.account_move_line_id:
currency = rma.account_move_line_id.currency_id