mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma_sale: Migration to v17
This commit is contained in:
committed by
JasminSForgeFlow
parent
7a823ab020
commit
6d5abdde93
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "RMA Sale",
|
||||
"version": "16.0.1.0.0",
|
||||
"version": "17.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "Links RMA with Sales Orders",
|
||||
|
||||
@@ -18,7 +18,7 @@ class StockRule(models.Model):
|
||||
company_id,
|
||||
values,
|
||||
):
|
||||
res = super(StockRule, self)._get_stock_move_values(
|
||||
res = super()._get_stock_move_values(
|
||||
product_id,
|
||||
product_qty,
|
||||
product_uom,
|
||||
|
||||
@@ -27,7 +27,7 @@ class RmaOrder(models.Model):
|
||||
("sale_line_id", "=", line.sale_line_id.id),
|
||||
]
|
||||
else:
|
||||
domain = super(RmaOrder, self)._get_line_domain(rma_id, line)
|
||||
domain = super()._get_line_domain(rma_id, line)
|
||||
return domain
|
||||
|
||||
def action_view_sale_order(self):
|
||||
|
||||
@@ -42,8 +42,6 @@ class RmaOrderLine(models.Model):
|
||||
string="Originating Sales Order Line",
|
||||
ondelete="restrict",
|
||||
copy=False,
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
)
|
||||
sale_id = fields.Many2one(
|
||||
string="Source Sales Order", related="sale_line_id.order_id"
|
||||
@@ -52,8 +50,6 @@ class RmaOrderLine(models.Model):
|
||||
comodel_name="sale.order.line",
|
||||
inverse_name="rma_line_id",
|
||||
string="Sales Order Lines",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
copy=False,
|
||||
)
|
||||
qty_to_sell = fields.Float(
|
||||
@@ -85,7 +81,7 @@ class RmaOrderLine(models.Model):
|
||||
@api.onchange("product_id", "partner_id")
|
||||
def _onchange_product_id(self):
|
||||
"""Domain for sale_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 = [
|
||||
@@ -100,7 +96,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.sale_policy = self.operation_id.sale_policy or "no"
|
||||
return res
|
||||
@@ -173,7 +169,7 @@ class RmaOrderLine(models.Model):
|
||||
self._remove_other_data_origin("sale_line_id")
|
||||
|
||||
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 == "sale_line_id":
|
||||
self.sale_line_id = False
|
||||
return res
|
||||
@@ -224,7 +220,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.sale_line_id:
|
||||
moves = self.sale_line_id.move_ids.filtered(
|
||||
lambda x: x.state == "done"
|
||||
|
||||
@@ -16,16 +16,14 @@ class SaleOrderLine(models.Model):
|
||||
(self._rec_name, operator, name),
|
||||
("order_id.name", operator, name),
|
||||
]
|
||||
return super(SaleOrderLine, 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(SaleOrderLine, self)._name_search(
|
||||
return super()._name_search(
|
||||
name="",
|
||||
args=args,
|
||||
operator=operator,
|
||||
@@ -35,7 +33,7 @@ class SaleOrderLine(models.Model):
|
||||
|
||||
def _get_sale_line_rma_name_get_label(self):
|
||||
self.ensure_one()
|
||||
return "SO:%s | INV: %s, | PART:%s | QTY:%s" % (
|
||||
return "SO:{} | INV: {}, | PART:{} | QTY:{}".format(
|
||||
self.order_id.name,
|
||||
" ".join(str(x) for x in [inv.name for inv in self.order_id.invoice_ids]),
|
||||
self.product_id.name,
|
||||
@@ -61,8 +59,6 @@ class SaleOrderLine(models.Model):
|
||||
)
|
||||
|
||||
def _prepare_order_line_procurement(self, group_id=False):
|
||||
vals = super(SaleOrderLine, self)._prepare_order_line_procurement(
|
||||
group_id=group_id
|
||||
)
|
||||
vals = super()._prepare_order_line_procurement(group_id=group_id)
|
||||
vals.update({"rma_line_id": self.rma_line_id.id})
|
||||
return vals
|
||||
|
||||
@@ -7,7 +7,7 @@ from odoo.tests import common
|
||||
class TestRmaSale(common.SingleTransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestRmaSale, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
|
||||
cls.rma_obj = cls.env["rma.order"]
|
||||
cls.rma_line_obj = cls.env["rma.order.line"]
|
||||
@@ -62,7 +62,6 @@ class TestRmaSale(common.SingleTransactionCase):
|
||||
},
|
||||
),
|
||||
],
|
||||
"pricelist_id": cls.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from odoo.addons.rma_account.tests.test_rma_stock_account import TestRmaStockAcc
|
||||
class TestRmaStockAccountSale(TestRmaStockAccount):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestRmaStockAccountSale, cls).setUpClass()
|
||||
super().setUpClass()
|
||||
cls.operation_receive_refund = cls.env.ref(
|
||||
"rma_account.rma_operation_customer_refund"
|
||||
)
|
||||
@@ -35,12 +35,12 @@ class TestRmaStockAccountSale(TestRmaStockAccount):
|
||||
},
|
||||
),
|
||||
],
|
||||
"pricelist_id": cls.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
cls.so1.action_confirm()
|
||||
for ml in cls.so1.picking_ids.move_line_ids:
|
||||
ml.qty_done = ml.reserved_uom_qty
|
||||
ml.quantity = ml.quantity_product_uom
|
||||
ml.picked = True
|
||||
cls.so1.picking_ids.button_validate()
|
||||
|
||||
def test_01_cost_from_so_move(self):
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
name="action_view_origin_sale_order"
|
||||
class="oe_stat_button"
|
||||
icon="fa-strikethrough"
|
||||
attrs="{'invisible': [('sale_id', '=', False)]}"
|
||||
invisible="sale_id == False"
|
||||
string="Origin Sale Order"
|
||||
>
|
||||
</button>
|
||||
@@ -21,7 +21,7 @@
|
||||
name="action_view_sale_order"
|
||||
class="oe_stat_button"
|
||||
icon="fa-strikethrough"
|
||||
attrs="{'invisible': [('sales_count', '=', 0)]}"
|
||||
invisible="sales_count == 0"
|
||||
groups="sales_team.group_sale_salesman_all_leads"
|
||||
>
|
||||
<field
|
||||
@@ -37,11 +37,12 @@
|
||||
name="sale_line_id"
|
||||
context="{'rma': True}"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'invisible':[('type', '!=', 'customer')]}"
|
||||
invisible="type != 'customer'"
|
||||
readonly="state != 'draft'"
|
||||
/>
|
||||
</group>
|
||||
<group name="quantities" position="inside">
|
||||
<group attrs="{'invisible': [('sale_policy', '=', 'no')]}">
|
||||
<group invisible="sale_policy == 'no'">
|
||||
<field name="qty_to_sell" />
|
||||
<field name="qty_sold" />
|
||||
</group>
|
||||
@@ -53,9 +54,13 @@
|
||||
<page
|
||||
name="sale"
|
||||
string="Sale Lines"
|
||||
attrs="{'invisible': [('sale_line_ids', '=', [])]}"
|
||||
invisible="sale_line_ids == []"
|
||||
>
|
||||
<field name="sale_line_ids" nolabel="1" />
|
||||
<field
|
||||
name="sale_line_ids"
|
||||
nolabel="1"
|
||||
readonly="state != 'draft'"
|
||||
/>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
@@ -71,13 +76,13 @@
|
||||
name="%(action_rma_order_line_make_sale_order)d"
|
||||
string="Create Sales Quotation"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible':['|', '|', '|', ('qty_to_sell', '=', 0), ('qty_to_sell', '<', 0), ('state', '!=', 'approved'), ('sale_policy', '=', 'no')]}"
|
||||
invisible="qty_to_sell == 0 or qty_to_sell < 0 or state != 'approved' or sale_policy == 'no'"
|
||||
type="action"
|
||||
/>
|
||||
<button
|
||||
name="%(action_rma_order_line_make_sale_order)d"
|
||||
string="Create Sales Quotation"
|
||||
attrs="{'invisible':['|', '|', ('qty_to_sell', '>', 0), ('state', '!=', 'approved'), ('sale_policy', '=', 'no')]}"
|
||||
invisible="qty_to_sell > 0 or state != 'approved' or sale_policy == 'no'"
|
||||
type="action"
|
||||
/>
|
||||
</header>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class="oe_stat_button"
|
||||
icon="fa-pencil-square-o"
|
||||
groups="sales_team.group_sale_salesman"
|
||||
attrs="{'invisible':[('type', '!=', 'customer')]}"
|
||||
invisible="type != 'customer'"
|
||||
>
|
||||
<field name="sale_count" widget="statinfo" string="Origin SO" />
|
||||
</button>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
name="action_view_rma"
|
||||
class="oe_stat_button"
|
||||
icon="fa-dropbox"
|
||||
attrs="{'invisible': [('rma_count', '=', 0)]}"
|
||||
invisible="rma_count == 0"
|
||||
groups="rma.group_rma_customer_user"
|
||||
>
|
||||
<field name="rma_count" widget="statinfo" string="RMA" />
|
||||
|
||||
@@ -11,7 +11,7 @@ class RmaAddSale(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaAddSale, 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"]
|
||||
@@ -197,8 +197,8 @@ class RmaAddSale(models.TransientModel):
|
||||
rec = rma_line_obj.create(data)
|
||||
# Ensure that configuration on the operation is applied
|
||||
# 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()
|
||||
rma = self.rma_id
|
||||
|
||||
@@ -44,23 +44,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
|
||||
@@ -68,7 +65,7 @@
|
||||
type="object"
|
||||
string="Select all"
|
||||
class="oe_inline"
|
||||
attrs="{'invisible': [('show_lot_filter', '=', False)]}"
|
||||
invisible="show_lot_filter == False"
|
||||
/>
|
||||
</div>
|
||||
<footer>
|
||||
@@ -114,7 +111,7 @@
|
||||
name="%(action_rma_add_sale)d"
|
||||
string="Add From Sale Order"
|
||||
type="action"
|
||||
attrs="{'invisible':[('type', '!=', 'customer')]}"
|
||||
invisible="type != 'customer'"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -8,7 +8,7 @@ class RmaMakePicking(models.TransientModel):
|
||||
|
||||
@api.returns("rma.order.line")
|
||||
def _prepare_item(self, line):
|
||||
res = super(RmaMakePicking, self)._prepare_item(line)
|
||||
res = super()._prepare_item(line)
|
||||
res["sale_line_id"] = line.sale_line_id.id
|
||||
return res
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(RmaLineMakeSaleOrder, 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,12 +8,12 @@ class RmaRefund(models.TransientModel):
|
||||
|
||||
@api.returns("rma.order.line")
|
||||
def _prepare_item(self, line):
|
||||
res = super(RmaRefund, self)._prepare_item(line)
|
||||
res = super()._prepare_item(line)
|
||||
res["sale_line_id"] = line.sale_line_id.id
|
||||
return res
|
||||
|
||||
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.operation_id.refund_free_of_charge:
|
||||
return price_unit
|
||||
if rma.type == "customer":
|
||||
|
||||
Reference in New Issue
Block a user