mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma_purchase: Migration to v17
This commit is contained in:
committed by
JasminSForgeFlow
parent
bfc8233feb
commit
ef3c219a8f
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -22,16 +22,14 @@ class PurchaseOrderLine(models.Model):
|
||||
(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 @@ class PurchaseOrderLine(models.Model):
|
||||
res.append(
|
||||
(
|
||||
purchase.id,
|
||||
"%s %s %s qty:%s"
|
||||
% (
|
||||
"{} {} {} qty:{}".format(
|
||||
purchase.order_id.name,
|
||||
" ".join(
|
||||
str(x)
|
||||
@@ -68,11 +65,12 @@ class PurchaseOrderLine(models.Model):
|
||||
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)
|
||||
|
||||
@@ -43,8 +43,6 @@ class RmaOrderLine(models.Model):
|
||||
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 @@ class RmaOrderLine(models.Model):
|
||||
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 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
@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 @@ class RmaOrderLine(models.Model):
|
||||
)
|
||||
|
||||
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 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
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:
|
||||
|
||||
@@ -7,7 +7,7 @@ from odoo.tests import common
|
||||
|
||||
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"]
|
||||
|
||||
@@ -11,7 +11,7 @@ from odoo.addons.rma_account.tests.test_rma_stock_account import TestRmaStockAcc
|
||||
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(
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<button
|
||||
name="%(action_rma_order_line_make_purchase_order)d"
|
||||
string="Create Purchase Order"
|
||||
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"
|
||||
/>
|
||||
</header>
|
||||
@@ -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"
|
||||
>
|
||||
<field
|
||||
name="purchase_count"
|
||||
@@ -54,10 +54,11 @@
|
||||
domain="['|',
|
||||
('order_id.partner_id', '=', partner_id),
|
||||
('order_id.partner_id', 'child_of', partner_id)]"
|
||||
readonly="state not in ['draft']"
|
||||
/>
|
||||
</group>
|
||||
<group name="quantities" position="inside">
|
||||
<group attrs="{'invisible': [('purchase_policy', '=', 'no')]}">
|
||||
<group invisible="purchase_policy == 'no'">
|
||||
<field name="qty_to_purchase" />
|
||||
<field name="qty_purchased" />
|
||||
</group>
|
||||
@@ -66,10 +67,7 @@
|
||||
<field name="purchase_policy" />
|
||||
</field>
|
||||
<field name="origin" position="after">
|
||||
<field
|
||||
name="purchase_id"
|
||||
attrs="{'invisible': [('purchase_order_line_id', '=', False)]}"
|
||||
/>
|
||||
<field name="purchase_id" invisible="purchase_order_line_id == False" />
|
||||
</field>
|
||||
<notebook position="inside">
|
||||
<page name="purchase" string="Purchase Lines">
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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 @@ class RmaMakePicking(models.TransientModel):
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -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 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
|
||||
@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"]
|
||||
|
||||
@@ -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 @@ class RmaRefund(models.TransientModel):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user