Skip to content

Commit

Permalink
[MIG] rma_account: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminSForgeFlow committed Nov 28, 2024
1 parent 88d09a0 commit 21d35e3
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 50 deletions.
2 changes: 1 addition & 1 deletion rma_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "RMA Account",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Integrates RMA with Invoice Processing",
Expand Down
8 changes: 4 additions & 4 deletions rma_account/models/rma_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ def _prepare_rma_data(self, partner, origin_rma):
def action_view_invoice_refund(self):
move_ids = self.mapped("rma_line_ids.move_id").ids
form_view_ref = self.env.ref("account.view_move_form", False)
tree_view_ref = self.env.ref("account.view_move_tree", False)
list_view_ref = self.env.ref("account.view_move_tree", False)

return {
"domain": [("id", "in", move_ids)],
"name": "Refunds",
"res_model": "account.move",
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
}

def action_view_invoice(self):
move_ids = self.mapped("rma_line_ids.move_id").ids
form_view_ref = self.env.ref("account.view_move_form", False)
tree_view_ref = self.env.ref("account.view_move_tree", False)
list_view_ref = self.env.ref("account.view_move_tree", False)

return {
"domain": [("id", "in", move_ids)],
"name": "Originating Invoice",
"res_model": "account.move",
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
}
8 changes: 4 additions & 4 deletions rma_account/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,27 +281,27 @@ def _check_duplicated_lines(self):

def action_view_invoice(self):
form_view_ref = self.env.ref("account.view_move_form", False)
tree_view_ref = self.env.ref("account.view_move_tree", False)
list_view_ref = self.env.ref("account.view_move_tree", False)

return {
"domain": [("id", "in", [self.account_move_line_id.move_id.id])],
"name": "Originating Invoice",
"res_model": "account.move",
"type": "ir.actions.act_window",
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
}

def action_view_refunds(self):
moves = self.mapped("refund_line_ids.move_id")
form_view_ref = self.env.ref("account.view_move_form", False)
tree_view_ref = self.env.ref("account.view_move_tree", False)
list_view_ref = self.env.ref("account.view_move_tree", False)

return {
"domain": [("id", "in", moves.ids)],
"name": "Refunds",
"res_model": "account.move",
"type": "ir.actions.act_window",
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
}

def _compute_display_name(self):
Expand Down
4 changes: 2 additions & 2 deletions rma_account/tests/test_account_move_line_rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _create_account(cls, acc_type, name, code, company, reconcile=False):
"name": name,
"code": code,
"account_type": acc_type,
"company_id": company.id,
"company_ids": [(4, company.id)],
"reconcile": reconcile,
}
)
Expand All @@ -110,7 +110,7 @@ def _create_product(cls):
{
"name": "test_product",
"categ_id": product_ctg.id,
"type": "product",
"is_storable": True,
"standard_price": 1.0,
"list_price": 1.0,
}
Expand Down
7 changes: 3 additions & 4 deletions rma_account/tests/test_rma_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from odoo import fields
from odoo.fields import Date
from odoo.tests import common
from odoo.tests.common import Form
from odoo.tests import Form, common


class TestRmaAccount(common.SingleTransactionCase):
Expand Down Expand Up @@ -68,7 +67,7 @@ def setUpClass(cls):
cls.product_1 = cls.product_obj.create(
{
"name": "Test Product 1",
"type": "product",
"is_storable": True,
"list_price": 100.0,
"rma_customer_operation_id": cls.cust_refund_op.id,
"rma_supplier_operation_id": cls.sup_refund_op.id,
Expand All @@ -77,7 +76,7 @@ def setUpClass(cls):
cls.product_2 = cls.product_obj.create(
{
"name": "Test Product 2",
"type": "product",
"is_storable": True,
"list_price": 150.0,
"rma_customer_operation_id": cls.operation_1.id,
"rma_supplier_operation_id": cls.sup_refund_op.id,
Expand Down
4 changes: 2 additions & 2 deletions rma_account/tests/test_rma_stock_account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2017-22 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

from odoo.tests.common import Form
from odoo.tests import Form

# pylint: disable=odoo-addons-relative-import
from odoo.addons.rma.tests.test_rma import TestRma
Expand Down Expand Up @@ -71,7 +71,7 @@ def _create_account(cls, acc_type, name, code, company, reconcile):
"name": name,
"code": code,
"account_type": acc_type,
"company_id": company.id,
"company_ids": [(4, company.id)],
"reconcile": reconcile,
}
)
Expand Down
8 changes: 4 additions & 4 deletions rma_account/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
</div>
<!-- Add link to rma_line_id to account.move.line -->
<xpath
expr="//field[@name='invoice_line_ids']/tree/field[@name='company_id']"
expr="//field[@name='invoice_line_ids']/list/field[@name='company_id']"
position="after"
>
<field name="rma_line_id" invisible="1" />
</xpath>
<xpath
expr="//field[@name='line_ids']/tree/field[@name='company_id']"
expr="//field[@name='line_ids']/list/field[@name='company_id']"
position="after"
>
<field name="rma_line_id" invisible="1" />
Expand All @@ -60,7 +60,7 @@
<field name="rma_line_id" />
</group>
<group name="rma_line" string="RMA Lines">
<field name="rma_line_ids" colspan="4" nolabel="1" />
<field name="rma_line_ids" colspan="4" nolabel="1" />
</group>
</page>
</xpath>
Expand All @@ -74,7 +74,7 @@
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<field name="invoice_vendor_bill_id" position="after">
<field
<field
name="add_rma_line_id"
context="{'rma': True}"
domain="[('type', '=', 'supplier'),('partner_id', '=', partner_id)]"
Expand Down
4 changes: 2 additions & 2 deletions rma_account/views/rma_account_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<field name="res_model">rma.order.line</field>
<field name="domain">[('type','=', 'customer')]</field>
<field name="context">{"search_default_to_refund":1}</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>

<record id="action_rma_supplier_lines" model="ir.actions.act_window">
<field name="name">Supplier RMA</field>
<field name="res_model">rma.order.line</field>
<field name="domain">[('type','=', 'supplier')]</field>
<field name="context">{"search_default_to_refund":1, "supplier":1}</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" ref="rma.view_rma_line_supplier_tree" />
</record>

Expand Down
2 changes: 1 addition & 1 deletion rma_account/views/rma_operation_view.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<odoo>
<record id="rma_operation_tree" model="ir.ui.view">
<field name="name">rma.operation.tree</field>
<field name="name">rma.operation.list</field>
<field name="model">rma.operation</field>
<field name="inherit_id" ref="rma.rma_operation_tree" />
<field name="arch" type="xml">
Expand Down
6 changes: 3 additions & 3 deletions rma_account/views/rma_order_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
string="Origin Inv"
>
</button>
<button
<button
type="object"
name="action_view_refunds"
class="oe_stat_button"
icon="fa-pencil-square-o"
invisible="refund_count == 0"
groups="account.group_account_invoice"
>
<field name="refund_count" widget="statinfo" string="Refunds" />
</button>
<field name="refund_count" widget="statinfo" string="Refunds" />
</button>
</button>
<group name="main_info" position="inside">
<field name="commercial_partner_id" invisible="1" />
Expand Down
2 changes: 1 addition & 1 deletion rma_account/views/rma_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<field name="invoice_count" widget="statinfo" string="Origin Inv" />
</button>
</button>
<xpath expr="//field[@name='rma_line_ids']/tree" position="inside">
<xpath expr="//field[@name='rma_line_ids']/list" position="inside">
<field name="refund_policy" invisible="True" />
</xpath>
</field>
Expand Down
16 changes: 6 additions & 10 deletions rma_account/wizards/rma_add_account_move.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
name="line_ids"
domain="[('move_id.partner_id', '=', partner_id)]"
>
<tree name="Invoice Lines">
<list name="Invoice Lines">
<field name="move_id" />
<field name="name" />
<field
Expand All @@ -28,17 +28,15 @@
<field name="discount" groups="base.group_no_one" />
<field name="price_subtotal" />
<field name="currency_id" invisible="1" />
</tree>
</list>
</field>
<footer>
<button
string="Confirm"
name="add_lines"
type="object"
class="oe_highlight"
/>
or
<button
/> or <button
name="action_cancel"
string="Cancel"
class="oe_link"
Expand All @@ -62,7 +60,7 @@
name="line_ids"
domain="[('move_id.partner_id', '=', partner_id)]"
>
<tree name="Invoice Lines">
<list name="Invoice Lines">
<field name="move_id" />
<field name="name" />
<field
Expand All @@ -76,17 +74,15 @@
<field name="discount" groups="base.group_no_one" />
<field name="price_subtotal" />
<field name="currency_id" invisible="1" />
</tree>
</list>
</field>
<footer>
<button
string="Confirm"
name="add_lines"
type="object"
class="oe_highlight"
/>
or
<button
/> or <button
name="action_cancel"
string="Cancel"
class="oe_link"
Expand Down
2 changes: 1 addition & 1 deletion rma_account/wizards/rma_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def invoice_refund(self):
if (new_invoice.move_type in ["out_refund", "out_invoice"])
else "action_move_in_refund_type"
)
result = self.env.ref("account.%s" % action).sudo().read()[0]
result = self.env.ref(f"account.{action}").sudo().read()[0]
form_view = self.env.ref("account.move_supplier_form", False)
result["views"] = [(form_view and form_view.id or False, "form")]
result["res_id"] = new_invoice.id
Expand Down
22 changes: 11 additions & 11 deletions rma_account/wizards/rma_refund.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<field name="arch" type="xml">
<form string="Credit Note">
<group>
<group>
<field name="description" />
</group>
<group>
<field name="date_invoice" />
<field name="date" />
</group>
<group>
<field name="description" />
</group>
<group>
<field name="date_invoice" />
<field name="date" />
</group>
</group>
<field name="item_ids">
<tree name="RMA Lines" editable="bottom">
<list name="RMA Lines" editable="bottom">
<field name="rma_id" invisible="1" readonly="1" />
<field name="product_id" invisible="1" readonly="1" />
<field name="product" />
Expand All @@ -24,7 +24,7 @@
<field name="product_qty" readonly="1" />
<field name="uom_id" groups="uom.group_uom" readonly="1" />
<field name="qty_to_refund" readonly="0" />
</tree>
</list>
</field>
<footer>
<button
Expand All @@ -35,14 +35,14 @@
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</form>
</field>
</record>

<record id="action_rma_refund" model="ir.actions.act_window">
<field name="name">Create Refund</field>
<field name="res_model">rma.refund</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" ref="view_rma_refund" />
<field name="binding_model_id" ref="rma.model_rma_order_line" />
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]" />
Expand Down

0 comments on commit 21d35e3

Please sign in to comment.