mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma_operating_unit: migration to 14.0
This commit is contained in:
committed by
Aaron ForgeFlow
parent
cddc0324cf
commit
7737ceddfb
@@ -24,10 +24,11 @@ Usage
|
|||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Aaron Henriquez <ahenriquez@eficent.com>
|
* Aaron Henriquez <ahenriquez@forgeflow.com>
|
||||||
* Beñat Jimenez <benat.jimenez@eficent.com>
|
* Beñat Jimenez <benat.jimenez@forgeflow.com>
|
||||||
|
* Juany Davila <juany.davila@forgeflow.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
||||||
This module is maintained by Eficent.
|
This module is maintained by ForgeFlow.
|
||||||
|
|||||||
@@ -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).
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Operating Unit in RMA Groups",
|
"name": "Operating Unit in RMA Groups",
|
||||||
"version": "12.0.1.0.0",
|
"version": "14.0.1.0.0",
|
||||||
"author": "Eficent",
|
"author": "ForgeFlow",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||||
"category": "Operating Units",
|
"category": "Operating Units",
|
||||||
|
|||||||
@@ -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).
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
@@ -9,7 +9,6 @@ class RmaOrder(models.Model):
|
|||||||
|
|
||||||
_inherit = "rma.order"
|
_inherit = "rma.order"
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("rma_line_ids", "rma_line_ids.operating_unit_id")
|
@api.constrains("rma_line_ids", "rma_line_ids.operating_unit_id")
|
||||||
def _check_operating_unit(self):
|
def _check_operating_unit(self):
|
||||||
for rma in self:
|
for rma in self:
|
||||||
|
|||||||
@@ -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).
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?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) -->
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<data noupdate="0">
|
<data noupdate="0">
|
||||||
|
|||||||
@@ -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).
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||||
from odoo import exceptions
|
from odoo import exceptions
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
@@ -68,21 +68,32 @@ class TestRmaOperatingUnit(common.TransactionCase):
|
|||||||
def _create_rma(self, uid, operating_unit=False):
|
def _create_rma(self, uid, operating_unit=False):
|
||||||
"""Creates an RMA"""
|
"""Creates an RMA"""
|
||||||
if not operating_unit:
|
if not operating_unit:
|
||||||
operating_unit = self.rma_model.sudo(uid)._default_operating_unit()
|
operating_unit = (
|
||||||
rma_order = self.rma_model.sudo(uid).create(
|
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,
|
"operating_unit_id": operating_unit.id,
|
||||||
"partner_id": self.partner.id,
|
"partner_id": self.partner.id,
|
||||||
"user_id": uid,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
)
|
||||||
return rma_order
|
return rma_order
|
||||||
|
|
||||||
def _create_rma_line(self, rma, uid, operating_unit):
|
def _create_rma_line(self, rma, uid, operating_unit):
|
||||||
"""Creates an RMA"""
|
"""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,
|
"operating_unit_id": operating_unit.id,
|
||||||
|
"operation_id": self.env.ref(
|
||||||
|
"rma.rma_operation_supplier_replace"
|
||||||
|
).id,
|
||||||
"rma_id": rma.id,
|
"rma_id": rma.id,
|
||||||
"partner_id": self.partner.id,
|
"partner_id": self.partner.id,
|
||||||
"in_route_id": 1,
|
"in_route_id": 1,
|
||||||
@@ -97,17 +108,22 @@ class TestRmaOperatingUnit(common.TransactionCase):
|
|||||||
"uom_id": self.product.uom_id.id,
|
"uom_id": self.product.uom_id.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
)
|
||||||
return rma_order_line
|
return rma_order_line
|
||||||
|
|
||||||
def test_security(self):
|
def test_security(self):
|
||||||
# User 2 is only assigned to Operating Unit B2C, and cannot
|
# User 2 is only assigned to Operating Unit B2C, and cannot
|
||||||
# access RMA of Main Operating Unit.
|
# 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),
|
("id", "=", self.rma_order1.id),
|
||||||
("operating_unit_id", "=", self.main_OU.id),
|
("operating_unit_id", "=", self.main_OU.id),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
record.ids,
|
record.ids,
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" ?>
|
<?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) -->
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_rma_line_tree" model="ir.ui.view">
|
<record id="view_rma_line_tree" model="ir.ui.view">
|
||||||
@@ -30,19 +30,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</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">
|
<record id="view_rma_line_supplier_form" model="ir.ui.view">
|
||||||
<field name="name">rma.order.line.supplier.form</field>
|
<field name="name">rma.order.line.supplier.form</field>
|
||||||
<field name="model">rma.order.line</field>
|
<field name="model">rma.order.line</field>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" ?>
|
<?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) -->
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_rma_tree" model="ir.ui.view">
|
<record id="view_rma_tree" model="ir.ui.view">
|
||||||
@@ -35,7 +35,8 @@
|
|||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
|
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
|
||||||
<field name="arch" type="xml">
|
<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="company_id" invisible="True" />
|
||||||
<field
|
<field
|
||||||
name="operating_unit_id"
|
name="operating_unit_id"
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
groups="operating_unit.group_multi_operating_unit"
|
groups="operating_unit.group_multi_operating_unit"
|
||||||
/>
|
/>
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -52,7 +54,8 @@
|
|||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_form" />
|
<field name="inherit_id" ref="rma.view_rma_form" />
|
||||||
<field name="arch" type="xml">
|
<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="company_id" invisible="True" />
|
||||||
<field
|
<field
|
||||||
name="operating_unit_id"
|
name="operating_unit_id"
|
||||||
@@ -61,6 +64,7 @@
|
|||||||
groups="operating_unit.group_multi_operating_unit"
|
groups="operating_unit.group_multi_operating_unit"
|
||||||
/>
|
/>
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
@@ -33,7 +33,7 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
[
|
[
|
||||||
("company_id", "=", self.rma_id.company_id.id),
|
("company_id", "=", self.rma_id.company_id.id),
|
||||||
("lot_rma_id", "!=", False),
|
("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,
|
limit=1,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user