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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
{
|
{
|
||||||
"name": "RMA Purchase",
|
"name": "RMA Purchase",
|
||||||
"version": "16.0.1.0.0",
|
"version": "17.0.1.0.0",
|
||||||
"category": "RMA",
|
"category": "RMA",
|
||||||
"summary": "RMA from PO",
|
"summary": "RMA from PO",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ class AccountMove(models.Model):
|
|||||||
_inherit = "account.move"
|
_inherit = "account.move"
|
||||||
|
|
||||||
def _prepare_invoice_line_from_rma_line(self, line):
|
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:
|
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
|
return data
|
||||||
|
|
||||||
def action_post(self):
|
def action_post(self):
|
||||||
res = super(AccountMove, self).action_post()
|
res = super().action_post()
|
||||||
for move in self:
|
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:
|
if rma_mls:
|
||||||
# Try to reconcile the interim accounts for RMA lines
|
# Try to reconcile the interim accounts for RMA lines
|
||||||
rmas = rma_mls.mapped("rma_line_id")
|
rmas = rma_mls.mapped("rma_line_id")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class PurchaseOrder(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def new(self, vals, origin=None, ref=None):
|
def new(self, vals, origin=None, ref=None):
|
||||||
"""Allows to propose a line based on the RMA information."""
|
"""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")
|
rma_line_id = self.env.context.get("rma_line_id")
|
||||||
if rma_line_id:
|
if rma_line_id:
|
||||||
rma_line = self.env["rma.order.line"].browse(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),
|
(self._rec_name, operator, name),
|
||||||
("order_id.name", operator, name),
|
("order_id.name", operator, name),
|
||||||
]
|
]
|
||||||
return super(PurchaseOrderLine, self).name_search(
|
return super().name_search(name=name, args=args, operator=operator, limit=limit)
|
||||||
name=name, args=args, operator=operator, limit=limit
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _name_search(
|
def _name_search(
|
||||||
self, name="", args=None, operator="ilike", limit=100, name_get_uid=None
|
self, name="", args=None, operator="ilike", limit=100, name_get_uid=None
|
||||||
):
|
):
|
||||||
"""Typed text is cleared here for better extensibility."""
|
"""Typed text is cleared here for better extensibility."""
|
||||||
return super(PurchaseOrderLine, self)._name_search(
|
return super()._name_search(
|
||||||
name="",
|
name="",
|
||||||
args=args,
|
args=args,
|
||||||
operator=operator,
|
operator=operator,
|
||||||
@@ -50,8 +48,7 @@ class PurchaseOrderLine(models.Model):
|
|||||||
res.append(
|
res.append(
|
||||||
(
|
(
|
||||||
purchase.id,
|
purchase.id,
|
||||||
"%s %s %s qty:%s"
|
"{} {} {} qty:{}".format(
|
||||||
% (
|
|
||||||
purchase.order_id.name,
|
purchase.order_id.name,
|
||||||
" ".join(
|
" ".join(
|
||||||
str(x)
|
str(x)
|
||||||
@@ -68,11 +65,12 @@ class PurchaseOrderLine(models.Model):
|
|||||||
res.append(super(PurchaseOrderLine, purchase).name_get()[0])
|
res.append(super(PurchaseOrderLine, purchase).name_get()[0])
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return super(PurchaseOrderLine, self).name_get()
|
return super().name_get()
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
|
for vals in vals_list:
|
||||||
rma_line_id = self.env.context.get("rma_line_id")
|
rma_line_id = self.env.context.get("rma_line_id")
|
||||||
if rma_line_id:
|
if rma_line_id:
|
||||||
vals["rma_line_id"] = rma_line_id
|
vals["rma_line_id"] = rma_line_id
|
||||||
return super(PurchaseOrderLine, self).create(vals)
|
return super().create(vals_list)
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ class RmaOrderLine(models.Model):
|
|||||||
comodel_name="purchase.order.line",
|
comodel_name="purchase.order.line",
|
||||||
string="Originating Purchase Line",
|
string="Originating Purchase Line",
|
||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
readonly=True,
|
|
||||||
states={"draft": [("readonly", False)]},
|
|
||||||
)
|
)
|
||||||
purchase_id = fields.Many2one(
|
purchase_id = fields.Many2one(
|
||||||
string="Source Purchase Order",
|
string="Source Purchase Order",
|
||||||
@@ -92,7 +90,7 @@ class RmaOrderLine(models.Model):
|
|||||||
def _onchange_product_id(self):
|
def _onchange_product_id(self):
|
||||||
"""Domain for purchase_order_line_id is computed here to make
|
"""Domain for purchase_order_line_id is computed here to make
|
||||||
it dynamic."""
|
it dynamic."""
|
||||||
res = super(RmaOrderLine, self)._onchange_product_id()
|
res = super()._onchange_product_id()
|
||||||
if not res.get("domain"):
|
if not res.get("domain"):
|
||||||
res["domain"] = {}
|
res["domain"] = {}
|
||||||
domain = [
|
domain = [
|
||||||
@@ -107,7 +105,7 @@ class RmaOrderLine(models.Model):
|
|||||||
|
|
||||||
@api.onchange("operation_id")
|
@api.onchange("operation_id")
|
||||||
def _onchange_operation_id(self):
|
def _onchange_operation_id(self):
|
||||||
res = super(RmaOrderLine, self)._onchange_operation_id()
|
res = super()._onchange_operation_id()
|
||||||
if self.operation_id:
|
if self.operation_id:
|
||||||
self.purchase_policy = self.operation_id.purchase_policy or "no"
|
self.purchase_policy = self.operation_id.purchase_policy or "no"
|
||||||
return res
|
return res
|
||||||
@@ -202,7 +200,7 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _remove_other_data_origin(self, exception):
|
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":
|
if not exception == "purchase_order_line_id":
|
||||||
self.purchase_order_line_id = False
|
self.purchase_order_line_id = False
|
||||||
return res
|
return res
|
||||||
@@ -233,7 +231,7 @@ class RmaOrderLine(models.Model):
|
|||||||
|
|
||||||
def _get_price_unit(self):
|
def _get_price_unit(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
price_unit = super(RmaOrderLine, self)._get_price_unit()
|
price_unit = super()._get_price_unit()
|
||||||
if self.purchase_order_line_id:
|
if self.purchase_order_line_id:
|
||||||
moves = self.purchase_order_line_id.move_ids
|
moves = self.purchase_order_line_id.move_ids
|
||||||
if moves:
|
if moves:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from odoo.tests import common
|
|||||||
|
|
||||||
class TestRmaPurchase(common.TransactionCase):
|
class TestRmaPurchase(common.TransactionCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRmaPurchase, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.rma_obj = self.env["rma.order"]
|
self.rma_obj = self.env["rma.order"]
|
||||||
self.rma_line_obj = self.env["rma.order.line"]
|
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):
|
class TestRmaStockAccountPurchase(TestRmaStockAccount):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestRmaStockAccountPurchase, cls).setUpClass()
|
super().setUpClass()
|
||||||
cls.pol_model = cls.env["purchase.order.line"]
|
cls.pol_model = cls.env["purchase.order.line"]
|
||||||
cls.po_model = cls.env["purchase.order"]
|
cls.po_model = cls.env["purchase.order"]
|
||||||
cls.rma_operation_supplier_refund = cls.env.ref(
|
cls.rma_operation_supplier_refund = cls.env.ref(
|
||||||
|
|||||||
@@ -18,15 +18,15 @@
|
|||||||
name="%(action_rma_order_line_make_purchase_order)d"
|
name="%(action_rma_order_line_make_purchase_order)d"
|
||||||
string="Create Purchase Order"
|
string="Create Purchase Order"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
attrs="{'invisible':['|', ('qty_to_purchase', '=', 0), ('state', '!=', 'approved')]}"
|
invisible="qty_to_purchase == 0 or state != 'approved'"
|
||||||
context="{'rma_line_id': active_id, 'default_partner_id': partner_id}"
|
context="{'rma_line_id': id, 'default_partner_id': partner_id}"
|
||||||
type="action"
|
type="action"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="%(action_rma_order_line_make_purchase_order)d"
|
name="%(action_rma_order_line_make_purchase_order)d"
|
||||||
string="Create Purchase Order"
|
string="Create Purchase Order"
|
||||||
attrs="{'invisible':['|', ('qty_to_purchase', '!=', 0), ('state', '!=', 'approved')]}"
|
invisible="qty_to_purchase != 0 or state != 'approved'"
|
||||||
context="{'rma_line_id': active_id, 'default_partner_id': partner_id}"
|
context="{'rma_line_id': id, 'default_partner_id': partner_id}"
|
||||||
type="action"
|
type="action"
|
||||||
/>
|
/>
|
||||||
</header>
|
</header>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-shopping-cart"
|
icon="fa-shopping-cart"
|
||||||
groups="purchase.group_purchase_user"
|
groups="purchase.group_purchase_user"
|
||||||
attrs="{'invisible':[('purchase_count','=',0)]}"
|
invisible="purchase_count == 0"
|
||||||
>
|
>
|
||||||
<field
|
<field
|
||||||
name="purchase_count"
|
name="purchase_count"
|
||||||
@@ -54,10 +54,11 @@
|
|||||||
domain="['|',
|
domain="['|',
|
||||||
('order_id.partner_id', '=', partner_id),
|
('order_id.partner_id', '=', partner_id),
|
||||||
('order_id.partner_id', 'child_of', partner_id)]"
|
('order_id.partner_id', 'child_of', partner_id)]"
|
||||||
|
readonly="state not in ['draft']"
|
||||||
/>
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group name="quantities" position="inside">
|
<group name="quantities" position="inside">
|
||||||
<group attrs="{'invisible': [('purchase_policy', '=', 'no')]}">
|
<group invisible="purchase_policy == 'no'">
|
||||||
<field name="qty_to_purchase" />
|
<field name="qty_to_purchase" />
|
||||||
<field name="qty_purchased" />
|
<field name="qty_purchased" />
|
||||||
</group>
|
</group>
|
||||||
@@ -66,10 +67,7 @@
|
|||||||
<field name="purchase_policy" />
|
<field name="purchase_policy" />
|
||||||
</field>
|
</field>
|
||||||
<field name="origin" position="after">
|
<field name="origin" position="after">
|
||||||
<field
|
<field name="purchase_id" invisible="purchase_order_line_id == False" />
|
||||||
name="purchase_id"
|
|
||||||
attrs="{'invisible': [('purchase_order_line_id', '=', False)]}"
|
|
||||||
/>
|
|
||||||
</field>
|
</field>
|
||||||
<notebook position="inside">
|
<notebook position="inside">
|
||||||
<page name="purchase" string="Purchase Lines">
|
<page name="purchase" string="Purchase Lines">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class RmaAddPurchase(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields_list):
|
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_obj = self.env["rma.order"]
|
||||||
rma_id = self.env.context["active_ids"] or []
|
rma_id = self.env.context["active_ids"] or []
|
||||||
active_model = self.env.context["active_model"]
|
active_model = self.env.context["active_model"]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
_inherit = "rma_make_picking.wizard"
|
_inherit = "rma_make_picking.wizard"
|
||||||
|
|
||||||
def _prepare_item(self, line):
|
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
|
res["purchase_order_line_id"] = line.purchase_order_line_id.id
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
result["domain"] = [("id", "in", po_list)]
|
result["domain"] = [("id", "in", po_list)]
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
action = super(RmaMakePicking, self)._get_action(pickings, procurements)
|
action = super()._get_action(pickings, procurements)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
|||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
comodel_name="res.partner",
|
comodel_name="res.partner",
|
||||||
required=False,
|
required=False,
|
||||||
readonly=1,
|
readonly=True,
|
||||||
)
|
)
|
||||||
item_ids = fields.One2many(
|
item_ids = fields.One2many(
|
||||||
comodel_name="rma.order.line.make.purchase.order.item",
|
comodel_name="rma.order.line.make.purchase.order.item",
|
||||||
@@ -42,7 +42,7 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields_list):
|
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_obj = self.env["rma.order.line"]
|
||||||
rma_line_ids = self.env.context["active_ids"] or []
|
rma_line_ids = self.env.context["active_ids"] or []
|
||||||
active_model = self.env.context["active_model"]
|
active_model = self.env.context["active_model"]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class RmaRefund(models.TransientModel):
|
|||||||
_inherit = "rma.refund"
|
_inherit = "rma.refund"
|
||||||
|
|
||||||
def _get_refund_price_unit(self, rma):
|
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.type == "supplier":
|
||||||
if rma.account_move_line_id:
|
if rma.account_move_line_id:
|
||||||
price_unit = rma.account_move_line_id.price_unit
|
price_unit = rma.account_move_line_id.price_unit
|
||||||
@@ -17,7 +17,7 @@ class RmaRefund(models.TransientModel):
|
|||||||
return price_unit
|
return price_unit
|
||||||
|
|
||||||
def _get_refund_currency(self, rma):
|
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.type == "supplier":
|
||||||
if rma.account_move_line_id:
|
if rma.account_move_line_id:
|
||||||
currency = rma.account_move_line_id.currency_id
|
currency = rma.account_move_line_id.currency_id
|
||||||
|
|||||||
Reference in New Issue
Block a user