mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] rma_operating_unit: black, isort, prettier
This commit is contained in:
committed by
Aaron ForgeFlow
parent
216b4ae897
commit
cddc0324cf
@@ -6,7 +6,7 @@
|
||||
"version": "12.0.1.0.0",
|
||||
"author": "Eficent",
|
||||
"license": "LGPL-3",
|
||||
"website": "https://www.eficent.com",
|
||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||
"category": "Operating Units",
|
||||
"depends": ["rma", "stock_operating_unit"],
|
||||
"data": [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# © 2017-19 Eficent Business and IT Consulting Services S.L.
|
||||
# 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
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -10,15 +10,19 @@ class RmaOrder(models.Model):
|
||||
_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):
|
||||
for rma in self:
|
||||
bad_lines = rma.rma_line_ids.filtered(
|
||||
lambda l: l.operating_unit_id != rma.operating_unit_id)
|
||||
lambda l: l.operating_unit_id != rma.operating_unit_id
|
||||
)
|
||||
if bad_lines:
|
||||
raise ValidationError(
|
||||
_('The operating unit of the rma lines have to match the'
|
||||
' one of the group'))
|
||||
_(
|
||||
"The operating unit of the rma lines have to match the"
|
||||
" one of the group"
|
||||
)
|
||||
)
|
||||
return True
|
||||
|
||||
@api.model
|
||||
@@ -26,7 +30,7 @@ class RmaOrder(models.Model):
|
||||
return self.env.user.default_operating_unit_id
|
||||
|
||||
operating_unit_id = fields.Many2one(
|
||||
comodel_name='operating.unit',
|
||||
string='Operating Unit',
|
||||
comodel_name="operating.unit",
|
||||
string="Operating Unit",
|
||||
default=_default_operating_unit,
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ class RmaOrderLine(models.Model):
|
||||
return self.env.user.default_operating_unit_id
|
||||
|
||||
operating_unit_id = fields.Many2one(
|
||||
comodel_name='operating.unit',
|
||||
string='Operating Unit',
|
||||
comodel_name="operating.unit",
|
||||
string="Operating Unit",
|
||||
default=_default_operating_unit,
|
||||
)
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<?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.
|
||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<record id="ir_rule_rma_allowed_operating_units"
|
||||
model="ir.rule">
|
||||
<field name="model_id" ref="rma.model_rma_order"/>
|
||||
<field name="domain_force">['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]</field>
|
||||
<record id="ir_rule_rma_allowed_operating_units" model="ir.rule">
|
||||
<field name="model_id" ref="rma.model_rma_order" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]</field>
|
||||
<field name="name">RMA from allowed operating units</field>
|
||||
<field name="global" eval="True"/>
|
||||
<field eval="0" name="perm_unlink"/>
|
||||
<field eval="0" name="perm_write"/>
|
||||
<field eval="1" name="perm_read"/>
|
||||
<field eval="0" name="perm_create"/>
|
||||
<field name="global" eval="True" />
|
||||
<field eval="0" name="perm_unlink" />
|
||||
<field eval="0" name="perm_write" />
|
||||
<field eval="1" name="perm_read" />
|
||||
<field eval="0" name="perm_create" />
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -1,45 +1,47 @@
|
||||
# © 2017-19 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
from odoo.tests import common
|
||||
from odoo import exceptions
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestRmaOperatingUnit(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRmaOperatingUnit, self).setUp()
|
||||
self.res_users_model = self.env['res.users']
|
||||
self.rma_model = self.env['rma.order']
|
||||
self.rma_line_model = self.env['rma.order.line']
|
||||
self.res_users_model = self.env["res.users"]
|
||||
self.rma_model = self.env["rma.order"]
|
||||
self.rma_line_model = self.env["rma.order.line"]
|
||||
|
||||
self.company = self.env.ref('base.main_company')
|
||||
self.partner = self.env.ref('base.res_partner_1')
|
||||
self.grp_rma_manager = self.env.ref('rma.group_rma_manager')
|
||||
self.company = self.env.ref("base.main_company")
|
||||
self.partner = self.env.ref("base.res_partner_1")
|
||||
self.grp_rma_manager = self.env.ref("rma.group_rma_manager")
|
||||
self.grp_ou = self.env.ref("operating_unit.group_multi_operating_unit")
|
||||
self.grp_stock = self.env.ref("stock.group_stock_manager")
|
||||
self.product = self.env.ref('product.product_product_12')
|
||||
self.product = self.env.ref("product.product_product_12")
|
||||
|
||||
# Main Operating Unit
|
||||
self.main_OU = self.env.ref('operating_unit.main_operating_unit')
|
||||
self.main_OU = self.env.ref("operating_unit.main_operating_unit")
|
||||
# B2C Operating Unit
|
||||
self.b2c_OU = self.env.ref('operating_unit.b2c_operating_unit')
|
||||
self.b2c_OU = self.env.ref("operating_unit.b2c_operating_unit")
|
||||
|
||||
# Users
|
||||
self.user1 = self._create_user('user_1',
|
||||
[self.grp_rma_manager, self.grp_ou,
|
||||
self.grp_stock],
|
||||
self.user1 = self._create_user(
|
||||
"user_1",
|
||||
[self.grp_rma_manager, self.grp_ou, self.grp_stock],
|
||||
self.company,
|
||||
[self.main_OU, self.b2c_OU])
|
||||
self.user2 = self._create_user('user_2',
|
||||
[self.grp_rma_manager, self.grp_ou,
|
||||
self.grp_stock],
|
||||
[self.main_OU, self.b2c_OU],
|
||||
)
|
||||
self.user2 = self._create_user(
|
||||
"user_2",
|
||||
[self.grp_rma_manager, self.grp_ou, self.grp_stock],
|
||||
self.company,
|
||||
[self.b2c_OU])
|
||||
self.user3 = self._create_user('user_3',
|
||||
[self.grp_rma_manager, self.grp_ou,
|
||||
self.grp_stock],
|
||||
[self.b2c_OU],
|
||||
)
|
||||
self.user3 = self._create_user(
|
||||
"user_3",
|
||||
[self.grp_rma_manager, self.grp_ou, self.grp_stock],
|
||||
self.company,
|
||||
[self.main_OU, self.b2c_OU])
|
||||
[self.main_OU, self.b2c_OU],
|
||||
)
|
||||
|
||||
# RMA Orders
|
||||
self.rma_order1 = self._create_rma(self.user1.id, self.main_OU)
|
||||
@@ -49,58 +51,68 @@ class TestRmaOperatingUnit(common.TransactionCase):
|
||||
def _create_user(self, login, groups, company, operating_units):
|
||||
"""Creates a user."""
|
||||
group_ids = [group.id for group in groups]
|
||||
user = self.res_users_model.create({
|
||||
'name': login,
|
||||
'login': login,
|
||||
'password': 'demo',
|
||||
'email': 'example@yourcompany.com',
|
||||
'company_id': company.id,
|
||||
'company_ids': [(4, company.id)],
|
||||
'operating_unit_ids': [(4, ou.id) for ou in operating_units],
|
||||
'groups_id': [(6, 0, group_ids)]
|
||||
})
|
||||
user = self.res_users_model.create(
|
||||
{
|
||||
"name": login,
|
||||
"login": login,
|
||||
"password": "demo",
|
||||
"email": "example@yourcompany.com",
|
||||
"company_id": company.id,
|
||||
"company_ids": [(4, company.id)],
|
||||
"operating_unit_ids": [(4, ou.id) for ou in operating_units],
|
||||
"groups_id": [(6, 0, group_ids)],
|
||||
}
|
||||
)
|
||||
return user
|
||||
|
||||
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_id': operating_unit.id,
|
||||
'partner_id': self.partner.id,
|
||||
'user_id': uid,
|
||||
})
|
||||
operating_unit = self.rma_model.sudo(uid)._default_operating_unit()
|
||||
rma_order = self.rma_model.sudo(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({
|
||||
'operating_unit_id': operating_unit.id,
|
||||
'rma_id': rma.id,
|
||||
'partner_id': self.partner.id,
|
||||
'in_route_id': 1,
|
||||
'out_route_id': 1,
|
||||
'in_warehouse_id': 1,
|
||||
'out_warehouse_id': 1,
|
||||
'location_id': 1,
|
||||
'receipt_policy': 'ordered',
|
||||
'delivery_policy': 'ordered',
|
||||
'name': self.product.name,
|
||||
'product_id': self.product.id,
|
||||
'uom_id': self.product.uom_id.id
|
||||
})
|
||||
rma_order_line = self.rma_line_model.sudo(uid).create(
|
||||
{
|
||||
"operating_unit_id": operating_unit.id,
|
||||
"rma_id": rma.id,
|
||||
"partner_id": self.partner.id,
|
||||
"in_route_id": 1,
|
||||
"out_route_id": 1,
|
||||
"in_warehouse_id": 1,
|
||||
"out_warehouse_id": 1,
|
||||
"location_id": 1,
|
||||
"receipt_policy": "ordered",
|
||||
"delivery_policy": "ordered",
|
||||
"name": self.product.name,
|
||||
"product_id": self.product.id,
|
||||
"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([('id', '=', self.rma_order1.id),
|
||||
('operating_unit_id', '=',
|
||||
self.main_OU.id)])
|
||||
self.assertEqual(record.ids, [], 'User 2 should not have access to '
|
||||
'OU %s.' % self.main_OU.name)
|
||||
record = self.rma_model.sudo(self.user2.id).search(
|
||||
[
|
||||
("id", "=", self.rma_order1.id),
|
||||
("operating_unit_id", "=", self.main_OU.id),
|
||||
]
|
||||
)
|
||||
self.assertEqual(
|
||||
record.ids,
|
||||
[],
|
||||
"User 2 should not have access to " "OU %s." % self.main_OU.name,
|
||||
)
|
||||
|
||||
def test_constraint(self):
|
||||
# RMA group should contain rma lines for the same OU
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" ?>
|
||||
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services 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">
|
||||
<field name="name">rma.order.line.tree</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_tree"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -16,10 +19,13 @@
|
||||
<record id="view_rma_line_supplier_tree" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.supplier.tree</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_tree"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -27,23 +33,31 @@
|
||||
<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="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
|
||||
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>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_form"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="origin" position="after">
|
||||
<field name="operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
<field name="operation_id" position="attributes">
|
||||
<attribute name="domain">[('type','=','supplier'),('out_warehouse_id.operating_unit_id', '=', operating_unit_id)]</attribute>
|
||||
<attribute
|
||||
name="domain"
|
||||
>[('type','=','supplier'),('out_warehouse_id.operating_unit_id', '=', operating_unit_id)]</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -51,13 +65,18 @@
|
||||
<record id="view_rma_line_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.form</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_form"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="origin" position="after">
|
||||
<field name="operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
<field name="operation_id" position="attributes">
|
||||
<attribute name="domain">[('type','=','customer'),('in_warehouse_id.operating_unit_id', '=', operating_unit_id)]</attribute>
|
||||
<attribute
|
||||
name="domain"
|
||||
>[('type','=','customer'),('in_warehouse_id.operating_unit_id', '=', operating_unit_id)]</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -65,10 +84,13 @@
|
||||
<record id="view_rma_rma_line_filter" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.select</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_rma_line_filter"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_rma_line_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" ?>
|
||||
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services 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">
|
||||
<field name="name">rma.order.tree</field>
|
||||
<field name="model">rma.order</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_tree"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_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
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -16,10 +19,13 @@
|
||||
<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="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
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -27,12 +33,16 @@
|
||||
<record id="view_rma_supplier_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.supplier.form</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">
|
||||
<group name="company" position="inside">
|
||||
<field name="company_id" invisible = "True"/>
|
||||
<field name="operating_unit_id" domain = "[('company_id','=', company_id)]"
|
||||
options="{'no_create': True}" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field name="company_id" invisible="True" />
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
domain="[('company_id','=', company_id)]"
|
||||
options="{'no_create': True}"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
@@ -40,12 +50,16 @@
|
||||
<record id="view_rma_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.form</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">
|
||||
<group name="company" position="inside">
|
||||
<field name="company_id" invisible = "True"/>
|
||||
<field name="operating_unit_id" domain = "[('company_id','=', company_id)]"
|
||||
options="{'no_create': True}" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field name="company_id" invisible="True" />
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
domain="[('company_id','=', company_id)]"
|
||||
options="{'no_create': True}"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
@@ -53,10 +67,13 @@
|
||||
<record id="view_rma_rma_filter" model="ir.ui.view">
|
||||
<field name="name">rma.order.select</field>
|
||||
<field name="model">rma.order</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_rma_filter"/>
|
||||
<field name="inherit_id" ref="rma.view_rma_rma_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
|
||||
<field
|
||||
name="operating_unit_id"
|
||||
groups="operating_unit.group_multi_operating_unit"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,37 +1,45 @@
|
||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo import models, _
|
||||
from odoo import _, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class RmaAddStockMove(models.TransientModel):
|
||||
_inherit = 'rma_add_stock_move'
|
||||
_description = 'Wizard to add rma lines from pickings'
|
||||
_inherit = "rma_add_stock_move"
|
||||
_description = "Wizard to add rma lines from pickings"
|
||||
|
||||
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||
res = super(RmaAddStockMove, self)._prepare_rma_line_from_stock_move(
|
||||
sm, lot)
|
||||
if self.env.context.get('customer'):
|
||||
operation = sm.product_id.rma_customer_operation_id or \
|
||||
sm.product_id.categ_id.rma_customer_operation_id
|
||||
res = super(RmaAddStockMove, self)._prepare_rma_line_from_stock_move(sm, lot)
|
||||
if self.env.context.get("customer"):
|
||||
operation = (
|
||||
sm.product_id.rma_customer_operation_id
|
||||
or sm.product_id.categ_id.rma_customer_operation_id
|
||||
)
|
||||
else:
|
||||
operation = sm.product_id.rma_supplier_operation_id or \
|
||||
sm.product_id.categ_id.rma_supplier_operation_id
|
||||
operation = (
|
||||
sm.product_id.rma_supplier_operation_id
|
||||
or sm.product_id.categ_id.rma_supplier_operation_id
|
||||
)
|
||||
if not operation:
|
||||
operation = self.env['rma.operation'].search(
|
||||
[('type', '=', self.rma_id.type)], limit=1)
|
||||
operation = self.env["rma.operation"].search(
|
||||
[("type", "=", self.rma_id.type)], limit=1
|
||||
)
|
||||
if not operation:
|
||||
raise ValidationError(_("Please define an operation first"))
|
||||
|
||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||
warehouse = self.env['stock.warehouse'].search(
|
||||
[('company_id', '=', self.rma_id.company_id.id),
|
||||
('lot_rma_id', '!=', False),
|
||||
('operating_unit_id', '=', self.line_id.operating_unit_id.id)
|
||||
], limit=1)
|
||||
warehouse = self.env["stock.warehouse"].search(
|
||||
[
|
||||
("company_id", "=", self.rma_id.company_id.id),
|
||||
("lot_rma_id", "!=", False),
|
||||
("operating_unit_id", "=", self.line_id.operating_unit_id.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
if not warehouse:
|
||||
raise ValidationError(_(
|
||||
"Please define a warehouse with a default RMA location"))
|
||||
raise ValidationError(
|
||||
_("Please define a warehouse with a default RMA location")
|
||||
)
|
||||
res.update(warehouse_id=warehouse.id)
|
||||
return res
|
||||
|
||||
1
setup/rma_operating_unit/odoo/addons/rma_operating_unit
Symbolic link
1
setup/rma_operating_unit/odoo/addons/rma_operating_unit
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../rma_operating_unit
|
||||
6
setup/rma_operating_unit/setup.py
Normal file
6
setup/rma_operating_unit/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user