[MIG] rma_operating_unit: migration to 14.0

This commit is contained in:
Juany Davila
2023-03-20 15:31:53 -05:00
committed by Aaron ForgeFlow
parent cddc0324cf
commit 7737ceddfb
9 changed files with 79 additions and 72 deletions

View File

@@ -24,10 +24,11 @@ Usage
Contributors
------------
* Aaron Henriquez <ahenriquez@eficent.com>
* Beñat Jimenez <benat.jimenez@eficent.com>
* Aaron Henriquez <ahenriquez@forgeflow.com>
* Beñat Jimenez <benat.jimenez@forgeflow.com>
* Juany Davila <juany.davila@forgeflow.com>
Maintainer
----------
This module is maintained by Eficent.
This module is maintained by ForgeFlow.

View File

@@ -1,10 +1,10 @@
# © 2017-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2017-19 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Operating Unit in RMA Groups",
"version": "12.0.1.0.0",
"author": "Eficent",
"version": "14.0.1.0.0",
"author": "ForgeFlow",
"license": "LGPL-3",
"website": "https://github.com/ForgeFlow/stock-rma",
"category": "Operating Units",

View File

@@ -1,4 +1,4 @@
# © 2017-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2017-23 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
@@ -9,7 +9,6 @@ class RmaOrder(models.Model):
_inherit = "rma.order"
@api.multi
@api.constrains("rma_line_ids", "rma_line_ids.operating_unit_id")
def _check_operating_unit(self):
for rma in self:

View File

@@ -1,4 +1,4 @@
# © 2017-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2017-19 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services S.L.
<!-- Copyright 2017-19 ForgeFlow S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<data noupdate="0">

View File

@@ -1,4 +1,4 @@
# © 2017-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2017-19 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import exceptions
from odoo.tests import common
@@ -68,21 +68,32 @@ class TestRmaOperatingUnit(common.TransactionCase):
def _create_rma(self, uid, operating_unit=False):
"""Creates an RMA"""
if not operating_unit:
operating_unit = self.rma_model.sudo(uid)._default_operating_unit()
rma_order = self.rma_model.sudo(uid).create(
operating_unit = (
self.rma_model.sudo().with_user(uid)._default_operating_unit()
)
rma_order = (
self.rma_model.sudo()
.with_user(uid)
.create(
{
"operating_unit_id": operating_unit.id,
"partner_id": self.partner.id,
"user_id": uid,
}
)
)
return rma_order
def _create_rma_line(self, rma, uid, operating_unit):
"""Creates an RMA"""
rma_order_line = self.rma_line_model.sudo(uid).create(
rma_order_line = (
self.rma_line_model.sudo()
.with_user(uid)
.create(
{
"operating_unit_id": operating_unit.id,
"operation_id": self.env.ref(
"rma.rma_operation_supplier_replace"
).id,
"rma_id": rma.id,
"partner_id": self.partner.id,
"in_route_id": 1,
@@ -97,17 +108,22 @@ class TestRmaOperatingUnit(common.TransactionCase):
"uom_id": self.product.uom_id.id,
}
)
)
return rma_order_line
def test_security(self):
# User 2 is only assigned to Operating Unit B2C, and cannot
# access RMA of Main Operating Unit.
record = self.rma_model.sudo(self.user2.id).search(
record = (
self.rma_model.sudo()
.with_user(self.user2.id)
.search(
[
("id", "=", self.rma_order1.id),
("operating_unit_id", "=", self.main_OU.id),
]
)
)
self.assertEqual(
record.ids,
[],

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services S.L.
<!-- Copyright 2017-19 ForgeFlow S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record id="view_rma_line_tree" model="ir.ui.view">
@@ -30,19 +30,6 @@
</field>
</record>
<record id="view_rma_supplier_tree" model="ir.ui.view">
<field name="name">rma.order.supplier.tree</field>
<field name="model">rma.order</field>
<field name="inherit_id" ref="rma.view_rma_supplier_tree" />
<field name="arch" type="xml">
<field name="date_rma" position="after">
<field
name="operating_unit_id"
groups="operating_unit.group_multi_operating_unit"
/>
</field>
</field>
</record>
<record id="view_rma_line_supplier_form" model="ir.ui.view">
<field name="name">rma.order.line.supplier.form</field>
<field name="model">rma.order.line</field>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services S.L.
<!-- Copyright 2017-19 ForgeFlow S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record id="view_rma_tree" model="ir.ui.view">
@@ -35,7 +35,8 @@
<field name="model">rma.order</field>
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
<field name="arch" type="xml">
<group name="company" position="inside">
<group name="comments" position="before">
<group name="company">
<field name="company_id" invisible="True" />
<field
name="operating_unit_id"
@@ -44,6 +45,7 @@
groups="operating_unit.group_multi_operating_unit"
/>
</group>
</group>
</field>
</record>
@@ -52,7 +54,8 @@
<field name="model">rma.order</field>
<field name="inherit_id" ref="rma.view_rma_form" />
<field name="arch" type="xml">
<group name="company" position="inside">
<group name="comments" position="before">
<group name="company">
<field name="company_id" invisible="True" />
<field
name="operating_unit_id"
@@ -61,6 +64,7 @@
groups="operating_unit.group_multi_operating_unit"
/>
</group>
</group>
</field>
</record>

View File

@@ -1,4 +1,4 @@
# © 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import _, models
@@ -33,7 +33,7 @@ class RmaAddStockMove(models.TransientModel):
[
("company_id", "=", self.rma_id.company_id.id),
("lot_rma_id", "!=", False),
("operating_unit_id", "=", self.line_id.operating_unit_id.id),
("operating_unit_id", "=", self.rma_id.operating_unit_id.id),
],
limit=1,
)