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",
|
"version": "12.0.1.0.0",
|
||||||
"author": "Eficent",
|
"author": "Eficent",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"website": "https://www.eficent.com",
|
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||||
"category": "Operating Units",
|
"category": "Operating Units",
|
||||||
"depends": ["rma", "stock_operating_unit"],
|
"depends": ["rma", "stock_operating_unit"],
|
||||||
"data": [
|
"data": [
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# © 2017-19 Eficent Business and IT Consulting Services S.L.
|
# © 2017-19 Eficent Business and IT Consulting Services 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
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@@ -10,15 +10,19 @@ class RmaOrder(models.Model):
|
|||||||
_inherit = "rma.order"
|
_inherit = "rma.order"
|
||||||
|
|
||||||
@api.multi
|
@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:
|
||||||
bad_lines = rma.rma_line_ids.filtered(
|
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:
|
if bad_lines:
|
||||||
raise ValidationError(
|
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
|
return True
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -26,7 +30,7 @@ class RmaOrder(models.Model):
|
|||||||
return self.env.user.default_operating_unit_id
|
return self.env.user.default_operating_unit_id
|
||||||
|
|
||||||
operating_unit_id = fields.Many2one(
|
operating_unit_id = fields.Many2one(
|
||||||
comodel_name='operating.unit',
|
comodel_name="operating.unit",
|
||||||
string='Operating Unit',
|
string="Operating Unit",
|
||||||
default=_default_operating_unit,
|
default=_default_operating_unit,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class RmaOrderLine(models.Model):
|
|||||||
return self.env.user.default_operating_unit_id
|
return self.env.user.default_operating_unit_id
|
||||||
|
|
||||||
operating_unit_id = fields.Many2one(
|
operating_unit_id = fields.Many2one(
|
||||||
comodel_name='operating.unit',
|
comodel_name="operating.unit",
|
||||||
string='Operating Unit',
|
string="Operating Unit",
|
||||||
default=_default_operating_unit,
|
default=_default_operating_unit,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data noupdate="0">
|
<data noupdate="0">
|
||||||
|
|
||||||
<record id="ir_rule_rma_allowed_operating_units"
|
<record id="ir_rule_rma_allowed_operating_units" model="ir.rule">
|
||||||
model="ir.rule">
|
|
||||||
<field name="model_id" ref="rma.model_rma_order" />
|
<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="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="name">RMA from allowed operating units</field>
|
||||||
<field name="global" eval="True" />
|
<field name="global" eval="True" />
|
||||||
<field eval="0" name="perm_unlink" />
|
<field eval="0" name="perm_unlink" />
|
||||||
|
|||||||
@@ -1,45 +1,47 @@
|
|||||||
# © 2017-19 Eficent Business and IT Consulting Services S.L.
|
# © 2017-19 Eficent Business and IT Consulting Services 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.tests import common
|
|
||||||
from odoo import exceptions
|
from odoo import exceptions
|
||||||
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
class TestRmaOperatingUnit(common.TransactionCase):
|
class TestRmaOperatingUnit(common.TransactionCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRmaOperatingUnit, self).setUp()
|
super(TestRmaOperatingUnit, self).setUp()
|
||||||
self.res_users_model = self.env['res.users']
|
self.res_users_model = self.env["res.users"]
|
||||||
self.rma_model = self.env['rma.order']
|
self.rma_model = self.env["rma.order"]
|
||||||
self.rma_line_model = self.env['rma.order.line']
|
self.rma_line_model = self.env["rma.order.line"]
|
||||||
|
|
||||||
self.company = self.env.ref('base.main_company')
|
self.company = self.env.ref("base.main_company")
|
||||||
self.partner = self.env.ref('base.res_partner_1')
|
self.partner = self.env.ref("base.res_partner_1")
|
||||||
self.grp_rma_manager = self.env.ref('rma.group_rma_manager')
|
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_ou = self.env.ref("operating_unit.group_multi_operating_unit")
|
||||||
self.grp_stock = self.env.ref("stock.group_stock_manager")
|
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
|
# 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
|
# 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
|
# Users
|
||||||
self.user1 = self._create_user('user_1',
|
self.user1 = self._create_user(
|
||||||
[self.grp_rma_manager, self.grp_ou,
|
"user_1",
|
||||||
self.grp_stock],
|
[self.grp_rma_manager, self.grp_ou, self.grp_stock],
|
||||||
self.company,
|
self.company,
|
||||||
[self.main_OU, self.b2c_OU])
|
[self.main_OU, self.b2c_OU],
|
||||||
self.user2 = self._create_user('user_2',
|
)
|
||||||
[self.grp_rma_manager, self.grp_ou,
|
self.user2 = self._create_user(
|
||||||
self.grp_stock],
|
"user_2",
|
||||||
|
[self.grp_rma_manager, self.grp_ou, self.grp_stock],
|
||||||
self.company,
|
self.company,
|
||||||
[self.b2c_OU])
|
[self.b2c_OU],
|
||||||
self.user3 = self._create_user('user_3',
|
)
|
||||||
[self.grp_rma_manager, self.grp_ou,
|
self.user3 = self._create_user(
|
||||||
self.grp_stock],
|
"user_3",
|
||||||
|
[self.grp_rma_manager, self.grp_ou, self.grp_stock],
|
||||||
self.company,
|
self.company,
|
||||||
[self.main_OU, self.b2c_OU])
|
[self.main_OU, self.b2c_OU],
|
||||||
|
)
|
||||||
|
|
||||||
# RMA Orders
|
# RMA Orders
|
||||||
self.rma_order1 = self._create_rma(self.user1.id, self.main_OU)
|
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):
|
def _create_user(self, login, groups, company, operating_units):
|
||||||
"""Creates a user."""
|
"""Creates a user."""
|
||||||
group_ids = [group.id for group in groups]
|
group_ids = [group.id for group in groups]
|
||||||
user = self.res_users_model.create({
|
user = self.res_users_model.create(
|
||||||
'name': login,
|
{
|
||||||
'login': login,
|
"name": login,
|
||||||
'password': 'demo',
|
"login": login,
|
||||||
'email': 'example@yourcompany.com',
|
"password": "demo",
|
||||||
'company_id': company.id,
|
"email": "example@yourcompany.com",
|
||||||
'company_ids': [(4, company.id)],
|
"company_id": company.id,
|
||||||
'operating_unit_ids': [(4, ou.id) for ou in operating_units],
|
"company_ids": [(4, company.id)],
|
||||||
'groups_id': [(6, 0, group_ids)]
|
"operating_unit_ids": [(4, ou.id) for ou in operating_units],
|
||||||
})
|
"groups_id": [(6, 0, group_ids)],
|
||||||
|
}
|
||||||
|
)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
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).\
|
operating_unit = self.rma_model.sudo(uid)._default_operating_unit()
|
||||||
_default_operating_unit()
|
rma_order = self.rma_model.sudo(uid).create(
|
||||||
rma_order = self.rma_model.sudo(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,
|
"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(uid).create(
|
||||||
'operating_unit_id': operating_unit.id,
|
{
|
||||||
'rma_id': rma.id,
|
"operating_unit_id": operating_unit.id,
|
||||||
'partner_id': self.partner.id,
|
"rma_id": rma.id,
|
||||||
'in_route_id': 1,
|
"partner_id": self.partner.id,
|
||||||
'out_route_id': 1,
|
"in_route_id": 1,
|
||||||
'in_warehouse_id': 1,
|
"out_route_id": 1,
|
||||||
'out_warehouse_id': 1,
|
"in_warehouse_id": 1,
|
||||||
'location_id': 1,
|
"out_warehouse_id": 1,
|
||||||
'receipt_policy': 'ordered',
|
"location_id": 1,
|
||||||
'delivery_policy': 'ordered',
|
"receipt_policy": "ordered",
|
||||||
'name': self.product.name,
|
"delivery_policy": "ordered",
|
||||||
'product_id': self.product.id,
|
"name": self.product.name,
|
||||||
'uom_id': self.product.uom_id.id
|
"product_id": self.product.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(
|
record = self.rma_model.sudo(self.user2.id).search(
|
||||||
self.user2.id).search([('id', '=', self.rma_order1.id),
|
[
|
||||||
('operating_unit_id', '=',
|
("id", "=", self.rma_order1.id),
|
||||||
self.main_OU.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)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
record.ids,
|
||||||
|
[],
|
||||||
|
"User 2 should not have access to " "OU %s." % self.main_OU.name,
|
||||||
|
)
|
||||||
|
|
||||||
def test_constraint(self):
|
def test_constraint(self):
|
||||||
# RMA group should contain rma lines for the same OU
|
# RMA group should contain rma lines for the same OU
|
||||||
|
|||||||
@@ -8,7 +8,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="state" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -19,7 +22,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="state" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -30,7 +36,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="date_rma" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -40,10 +49,15 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="origin" position="after">
|
<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>
|
||||||
<field name="operation_id" position="attributes">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -54,10 +68,15 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="origin" position="after">
|
<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>
|
||||||
<field name="operation_id" position="attributes">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -68,7 +87,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="partner_id" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -8,7 +8,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="date_rma" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -19,7 +22,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="date_rma" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -31,8 +37,12 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<group name="company" position="inside">
|
<group name="company" position="inside">
|
||||||
<field name="company_id" invisible="True" />
|
<field name="company_id" invisible="True" />
|
||||||
<field name="operating_unit_id" domain = "[('company_id','=', company_id)]"
|
<field
|
||||||
options="{'no_create': True}" groups="operating_unit.group_multi_operating_unit"/>
|
name="operating_unit_id"
|
||||||
|
domain="[('company_id','=', company_id)]"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
groups="operating_unit.group_multi_operating_unit"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -44,8 +54,12 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<group name="company" position="inside">
|
<group name="company" position="inside">
|
||||||
<field name="company_id" invisible="True" />
|
<field name="company_id" invisible="True" />
|
||||||
<field name="operating_unit_id" domain = "[('company_id','=', company_id)]"
|
<field
|
||||||
options="{'no_create': True}" groups="operating_unit.group_multi_operating_unit"/>
|
name="operating_unit_id"
|
||||||
|
domain="[('company_id','=', company_id)]"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
groups="operating_unit.group_multi_operating_unit"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -56,7 +70,10 @@
|
|||||||
<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="arch" type="xml">
|
||||||
<field name="partner_id" position="after">
|
<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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -1,37 +1,45 @@
|
|||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 Eficent Business and IT Consulting Services 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
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class RmaAddStockMove(models.TransientModel):
|
class RmaAddStockMove(models.TransientModel):
|
||||||
_inherit = 'rma_add_stock_move'
|
_inherit = "rma_add_stock_move"
|
||||||
_description = 'Wizard to add rma lines from pickings'
|
_description = "Wizard to add rma lines from pickings"
|
||||||
|
|
||||||
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||||
res = super(RmaAddStockMove, self)._prepare_rma_line_from_stock_move(
|
res = super(RmaAddStockMove, self)._prepare_rma_line_from_stock_move(sm, lot)
|
||||||
sm, lot)
|
if self.env.context.get("customer"):
|
||||||
if self.env.context.get('customer'):
|
operation = (
|
||||||
operation = sm.product_id.rma_customer_operation_id or \
|
sm.product_id.rma_customer_operation_id
|
||||||
sm.product_id.categ_id.rma_customer_operation_id
|
or sm.product_id.categ_id.rma_customer_operation_id
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
operation = sm.product_id.rma_supplier_operation_id or \
|
operation = (
|
||||||
sm.product_id.categ_id.rma_supplier_operation_id
|
sm.product_id.rma_supplier_operation_id
|
||||||
|
or sm.product_id.categ_id.rma_supplier_operation_id
|
||||||
|
)
|
||||||
if not operation:
|
if not operation:
|
||||||
operation = self.env['rma.operation'].search(
|
operation = self.env["rma.operation"].search(
|
||||||
[('type', '=', self.rma_id.type)], limit=1)
|
[("type", "=", self.rma_id.type)], limit=1
|
||||||
|
)
|
||||||
if not operation:
|
if not operation:
|
||||||
raise ValidationError(_("Please define an operation first"))
|
raise ValidationError(_("Please define an operation first"))
|
||||||
|
|
||||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
warehouse = self.env['stock.warehouse'].search(
|
warehouse = self.env["stock.warehouse"].search(
|
||||||
[('company_id', '=', self.rma_id.company_id.id),
|
[
|
||||||
('lot_rma_id', '!=', False),
|
("company_id", "=", self.rma_id.company_id.id),
|
||||||
('operating_unit_id', '=', self.line_id.operating_unit_id.id)
|
("lot_rma_id", "!=", False),
|
||||||
], limit=1)
|
("operating_unit_id", "=", self.line_id.operating_unit_id.id),
|
||||||
|
],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError(_(
|
raise ValidationError(
|
||||||
"Please define a warehouse with a default RMA location"))
|
_("Please define a warehouse with a default RMA location")
|
||||||
|
)
|
||||||
res.update(warehouse_id=warehouse.id)
|
res.update(warehouse_id=warehouse.id)
|
||||||
return res
|
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