mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] : black, isort
This commit is contained in:
committed by
Florian da Costa
parent
4c3be10830
commit
e0c8c99df4
@@ -5,43 +5,52 @@ from odoo import fields, models
|
||||
|
||||
|
||||
class StockRule(models.Model):
|
||||
_inherit = 'stock.rule'
|
||||
_inherit = "stock.rule"
|
||||
|
||||
rma_line_id = fields.Many2one(
|
||||
comodel_name='rma.order.line', string='RMA line',
|
||||
ondelete="set null",
|
||||
comodel_name="rma.order.line", string="RMA line", ondelete="set null"
|
||||
)
|
||||
|
||||
def _get_stock_move_values(self, product_id, product_qty, product_uom,
|
||||
location_id, name, origin, values, group_id):
|
||||
res = super(StockRule, self)._get_stock_move_values(product_id,
|
||||
product_qty,
|
||||
product_uom,
|
||||
location_id,
|
||||
name, origin,
|
||||
values, group_id)
|
||||
if 'rma_line_id' in values:
|
||||
line = self.env['rma.order.line'].browse(values.get('rma_line_id'))
|
||||
res['rma_line_id'] = line.id
|
||||
def _get_stock_move_values(
|
||||
self,
|
||||
product_id,
|
||||
product_qty,
|
||||
product_uom,
|
||||
location_id,
|
||||
name,
|
||||
origin,
|
||||
values,
|
||||
group_id,
|
||||
):
|
||||
res = super(StockRule, self)._get_stock_move_values(
|
||||
product_id,
|
||||
product_qty,
|
||||
product_uom,
|
||||
location_id,
|
||||
name,
|
||||
origin,
|
||||
values,
|
||||
group_id,
|
||||
)
|
||||
if "rma_line_id" in values:
|
||||
line = self.env["rma.order.line"].browse(values.get("rma_line_id"))
|
||||
res["rma_line_id"] = line.id
|
||||
if line.delivery_address_id:
|
||||
res['partner_id'] = line.delivery_address_id.id
|
||||
res["partner_id"] = line.delivery_address_id.id
|
||||
else:
|
||||
res['partner_id'] = line.rma_id.partner_id.id
|
||||
dest_loc = self.env["stock.location"].browse([
|
||||
res["location_dest_id"]])[0]
|
||||
res["partner_id"] = line.rma_id.partner_id.id
|
||||
dest_loc = self.env["stock.location"].browse([res["location_dest_id"]])[0]
|
||||
if dest_loc.usage == "internal":
|
||||
res["price_unit"] = line.price_unit
|
||||
return res
|
||||
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
_inherit = 'procurement.group'
|
||||
_inherit = "procurement.group"
|
||||
|
||||
rma_id = fields.Many2one(
|
||||
comodel_name='rma.order', string='RMA',
|
||||
ondelete="set null",
|
||||
comodel_name="rma.order", string="RMA", ondelete="set null"
|
||||
)
|
||||
rma_line_id = fields.Many2one(
|
||||
comodel_name='rma.order.line', string='RMA line',
|
||||
ondelete="set null",
|
||||
comodel_name="rma.order.line", string="RMA line", ondelete="set null"
|
||||
)
|
||||
|
||||
@@ -5,11 +5,14 @@ from odoo import fields, models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
_inherit = "product.template"
|
||||
|
||||
rma_customer_operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation", string="Default RMA Customer Operation")
|
||||
comodel_name="rma.operation", string="Default RMA Customer Operation"
|
||||
)
|
||||
rma_supplier_operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation", string="Default RMA Supplier Operation")
|
||||
comodel_name="rma.operation", string="Default RMA Supplier Operation"
|
||||
)
|
||||
rma_approval_policy = fields.Selection(
|
||||
related="categ_id.rma_approval_policy", readonly=True)
|
||||
related="categ_id.rma_approval_policy", readonly=True
|
||||
)
|
||||
|
||||
@@ -8,14 +8,19 @@ class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
rma_approval_policy = fields.Selection(
|
||||
selection=[('one_step', 'One step'), ('two_step', 'Two steps')],
|
||||
string="RMA Approval Policy", required=True, default='one_step',
|
||||
selection=[("one_step", "One step"), ("two_step", "Two steps")],
|
||||
string="RMA Approval Policy",
|
||||
required=True,
|
||||
default="one_step",
|
||||
help="Options: \n "
|
||||
"* One step: Always auto-approve RMAs that only contain "
|
||||
"products within categories with this policy.\n"
|
||||
"* Two steps: A RMA containing a product within a category with "
|
||||
"this policy will request the RMA manager approval.")
|
||||
"* One step: Always auto-approve RMAs that only contain "
|
||||
"products within categories with this policy.\n"
|
||||
"* Two steps: A RMA containing a product within a category with "
|
||||
"this policy will request the RMA manager approval.",
|
||||
)
|
||||
rma_customer_operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation", string="Default RMA Customer Operation")
|
||||
comodel_name="rma.operation", string="Default RMA Customer Operation"
|
||||
)
|
||||
rma_supplier_operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation", string="Default RMA Supplier Operation")
|
||||
comodel_name="rma.operation", string="Default RMA Supplier Operation"
|
||||
)
|
||||
|
||||
@@ -13,14 +13,13 @@ class ResPartner(models.Model):
|
||||
rec.rma_line_count = len(rec.rma_line_ids)
|
||||
|
||||
rma_line_ids = fields.One2many(
|
||||
comodel_name="rma.order.line", string="RMAs",
|
||||
inverse_name="partner_id",
|
||||
comodel_name="rma.order.line", string="RMAs", inverse_name="partner_id"
|
||||
)
|
||||
rma_line_count = fields.Integer(compute="_compute_rma_line_count")
|
||||
|
||||
@api.multi
|
||||
def action_open_partner_rma(self):
|
||||
action = self.env.ref('rma.action_rma_customer_lines')
|
||||
action = self.env.ref("rma.action_rma_customer_lines")
|
||||
result = action.read()[0]
|
||||
result['context'] = {'search_default_partner_id': self.id}
|
||||
result["context"] = {"search_default_partner_id": self.id}
|
||||
return result
|
||||
|
||||
@@ -5,77 +5,94 @@ from odoo import api, fields, models
|
||||
|
||||
|
||||
class RmaOperation(models.Model):
|
||||
_name = 'rma.operation'
|
||||
_description = 'RMA Operation'
|
||||
_name = "rma.operation"
|
||||
_description = "RMA Operation"
|
||||
|
||||
@api.model
|
||||
def _default_warehouse_id(self):
|
||||
company_id = self.env.user.company_id.id
|
||||
warehouse = self.env['stock.warehouse'].search(
|
||||
[('company_id', '=', company_id)], limit=1)
|
||||
warehouse = self.env["stock.warehouse"].search(
|
||||
[("company_id", "=", company_id)], limit=1
|
||||
)
|
||||
return warehouse
|
||||
|
||||
@api.model
|
||||
def _default_customer_location_id(self):
|
||||
return self.env.ref('stock.stock_location_customers') or False
|
||||
return self.env.ref("stock.stock_location_customers") or False
|
||||
|
||||
@api.model
|
||||
def _default_supplier_location_id(self):
|
||||
return self.env.ref('stock.stock_location_suppliers') or False
|
||||
return self.env.ref("stock.stock_location_suppliers") or False
|
||||
|
||||
@api.model
|
||||
def _default_routes(self):
|
||||
op_type = self.env.context.get('default_type')
|
||||
if op_type == 'customer':
|
||||
return self.env.ref('rma.route_rma_customer')
|
||||
elif op_type == 'supplier':
|
||||
return self.env.ref('rma.route_rma_supplier')
|
||||
op_type = self.env.context.get("default_type")
|
||||
if op_type == "customer":
|
||||
return self.env.ref("rma.route_rma_customer")
|
||||
elif op_type == "supplier":
|
||||
return self.env.ref("rma.route_rma_supplier")
|
||||
|
||||
name = fields.Char('Description', required=True)
|
||||
code = fields.Char('Code', required=True)
|
||||
active = fields.Boolean(string='Active', default=True)
|
||||
receipt_policy = fields.Selection([
|
||||
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
||||
('delivered', 'Based on Delivered Quantities')],
|
||||
string="Receipts Policy", default='no')
|
||||
delivery_policy = fields.Selection([
|
||||
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
||||
('received', 'Based on Received Quantities')],
|
||||
string="Delivery Policy", default='no')
|
||||
name = fields.Char("Description", required=True)
|
||||
code = fields.Char("Code", required=True)
|
||||
active = fields.Boolean(string="Active", default=True)
|
||||
receipt_policy = fields.Selection(
|
||||
[
|
||||
("no", "Not required"),
|
||||
("ordered", "Based on Ordered Quantities"),
|
||||
("delivered", "Based on Delivered Quantities"),
|
||||
],
|
||||
string="Receipts Policy",
|
||||
default="no",
|
||||
)
|
||||
delivery_policy = fields.Selection(
|
||||
[
|
||||
("no", "Not required"),
|
||||
("ordered", "Based on Ordered Quantities"),
|
||||
("received", "Based on Received Quantities"),
|
||||
],
|
||||
string="Delivery Policy",
|
||||
default="no",
|
||||
)
|
||||
in_route_id = fields.Many2one(
|
||||
comodel_name='stock.location.route', string='Inbound Route',
|
||||
domain=[('rma_selectable', '=', True)],
|
||||
comodel_name="stock.location.route",
|
||||
string="Inbound Route",
|
||||
domain=[("rma_selectable", "=", True)],
|
||||
default=lambda self: self._default_routes(),
|
||||
)
|
||||
out_route_id = fields.Many2one(
|
||||
comodel_name='stock.location.route', string='Outbound Route',
|
||||
domain=[('rma_selectable', '=', True)],
|
||||
comodel_name="stock.location.route",
|
||||
string="Outbound Route",
|
||||
domain=[("rma_selectable", "=", True)],
|
||||
default=lambda self: self._default_routes(),
|
||||
)
|
||||
customer_to_supplier = fields.Boolean(
|
||||
string='The customer will send to the supplier',
|
||||
string="The customer will send to the supplier"
|
||||
)
|
||||
supplier_to_customer = fields.Boolean(
|
||||
string='The supplier will send to the customer',
|
||||
string="The supplier will send to the customer"
|
||||
)
|
||||
in_warehouse_id = fields.Many2one(
|
||||
comodel_name='stock.warehouse', string='Inbound Warehouse',
|
||||
comodel_name="stock.warehouse",
|
||||
string="Inbound Warehouse",
|
||||
default=lambda self: self._default_warehouse_id(),
|
||||
)
|
||||
out_warehouse_id = fields.Many2one(
|
||||
comodel_name='stock.warehouse', string='Outbound Warehouse',
|
||||
comodel_name="stock.warehouse",
|
||||
string="Outbound Warehouse",
|
||||
default=lambda self: self._default_warehouse_id(),
|
||||
)
|
||||
location_id = fields.Many2one(
|
||||
'stock.location', 'Send To This Company Location')
|
||||
type = fields.Selection([
|
||||
('customer', 'Customer'), ('supplier', 'Supplier')],
|
||||
string="Used in RMA of this type", required=True)
|
||||
location_id = fields.Many2one("stock.location", "Send To This Company Location")
|
||||
type = fields.Selection(
|
||||
[("customer", "Customer"), ("supplier", "Supplier")],
|
||||
string="Used in RMA of this type",
|
||||
required=True,
|
||||
)
|
||||
rma_line_ids = fields.One2many(
|
||||
comodel_name='rma.order.line', inverse_name='operation_id',
|
||||
string='RMA lines',
|
||||
comodel_name="rma.order.line", inverse_name="operation_id", string="RMA lines"
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company', string='Company', required=True,
|
||||
default=lambda self: self.env.user.company_id
|
||||
comodel_name="res.company",
|
||||
string="Company",
|
||||
required=True,
|
||||
default=lambda self: self.env.user.company_id,
|
||||
)
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
# Copyright (C) 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 api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
from datetime import datetime
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class RmaOrder(models.Model):
|
||||
_name = "rma.order"
|
||||
_description = 'RMA Group'
|
||||
_inherit = ['mail.thread']
|
||||
_description = "RMA Group"
|
||||
_inherit = ["mail.thread"]
|
||||
|
||||
@api.model
|
||||
def _get_default_type(self):
|
||||
if 'supplier' in self.env.context:
|
||||
if "supplier" in self.env.context:
|
||||
return "supplier"
|
||||
return "customer"
|
||||
|
||||
@@ -23,7 +24,7 @@ class RmaOrder(models.Model):
|
||||
picking_ids = []
|
||||
for line in rec.rma_line_ids:
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage == 'internal':
|
||||
if move.location_dest_id.usage == "internal":
|
||||
picking_ids.append(move.picking_id.id)
|
||||
else:
|
||||
if line.customer_to_supplier:
|
||||
@@ -37,7 +38,7 @@ class RmaOrder(models.Model):
|
||||
for rec in self:
|
||||
for line in rec.rma_line_ids:
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage in ('supplier', 'customer'):
|
||||
if move.location_dest_id.usage in ("supplier", "customer"):
|
||||
if not line.customer_to_supplier:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
shipments = list(set(picking_ids))
|
||||
@@ -45,34 +46,36 @@ class RmaOrder(models.Model):
|
||||
|
||||
@api.multi
|
||||
def _compute_supplier_line_count(self):
|
||||
self.supplier_line_count = len(self.rma_line_ids.filtered(
|
||||
lambda r: r.supplier_rma_line_ids))
|
||||
self.supplier_line_count = len(
|
||||
self.rma_line_ids.filtered(lambda r: r.supplier_rma_line_ids)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _compute_line_count(self):
|
||||
for rec in self:
|
||||
rec.line_count = len(rec._get_valid_lines())
|
||||
|
||||
@api.depends('rma_line_ids', 'rma_line_ids.state')
|
||||
@api.depends("rma_line_ids", "rma_line_ids.state")
|
||||
@api.multi
|
||||
def _compute_state(self):
|
||||
for rec in self:
|
||||
rma_line_done = self.env['rma.order.line'].search_count(
|
||||
[('id', 'in', rec.rma_line_ids.ids), ('state', '=', 'done')])
|
||||
rma_line_approved = self.env['rma.order.line'].search_count(
|
||||
[('id', 'in', rec.rma_line_ids.ids),
|
||||
('state', '=', 'approved')])
|
||||
rma_line_to_approve = self.env['rma.order.line'].search_count(
|
||||
[('id', 'in', rec.rma_line_ids.ids),
|
||||
('state', '=', 'to_approve')])
|
||||
rma_line_done = self.env["rma.order.line"].search_count(
|
||||
[("id", "in", rec.rma_line_ids.ids), ("state", "=", "done")]
|
||||
)
|
||||
rma_line_approved = self.env["rma.order.line"].search_count(
|
||||
[("id", "in", rec.rma_line_ids.ids), ("state", "=", "approved")]
|
||||
)
|
||||
rma_line_to_approve = self.env["rma.order.line"].search_count(
|
||||
[("id", "in", rec.rma_line_ids.ids), ("state", "=", "to_approve")]
|
||||
)
|
||||
if rma_line_done != 0:
|
||||
state = 'done'
|
||||
state = "done"
|
||||
elif rma_line_approved != 0:
|
||||
state = 'approved'
|
||||
state = "approved"
|
||||
elif rma_line_to_approve != 0:
|
||||
state = 'to_approve'
|
||||
state = "to_approve"
|
||||
else:
|
||||
state = 'draft'
|
||||
state = "draft"
|
||||
rec.state = state
|
||||
|
||||
@api.model
|
||||
@@ -81,108 +84,114 @@ class RmaOrder(models.Model):
|
||||
|
||||
@api.model
|
||||
def _default_warehouse_id(self):
|
||||
warehouse = self.env['stock.warehouse'].search(
|
||||
[('company_id', '=', self.env.user.company_id.id)], limit=1)
|
||||
warehouse = self.env["stock.warehouse"].search(
|
||||
[("company_id", "=", self.env.user.company_id.id)], limit=1
|
||||
)
|
||||
return warehouse
|
||||
|
||||
name = fields.Char(
|
||||
string='Group Number', index=True, copy=False)
|
||||
name = fields.Char(string="Group Number", index=True, copy=False)
|
||||
type = fields.Selection(
|
||||
[('customer', 'Customer'), ('supplier', 'Supplier')],
|
||||
string="Type", required=True,
|
||||
[("customer", "Customer"), ("supplier", "Supplier")],
|
||||
string="Type",
|
||||
required=True,
|
||||
default=lambda self: self._get_default_type(),
|
||||
readonly=True
|
||||
readonly=True,
|
||||
)
|
||||
reference = fields.Char(
|
||||
string="Partner Reference", help="The partner reference of this RMA order."
|
||||
)
|
||||
comment = fields.Text("Additional Information")
|
||||
date_rma = fields.Datetime(
|
||||
string="Order Date", index=True, default=lambda self: self._default_date_rma()
|
||||
)
|
||||
reference = fields.Char(string='Partner Reference',
|
||||
help="The partner reference of this RMA order.")
|
||||
comment = fields.Text('Additional Information')
|
||||
date_rma = fields.Datetime(string='Order Date', index=True,
|
||||
default=lambda self: self._default_date_rma(),)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner', string='Partner', required=True)
|
||||
rma_line_ids = fields.One2many('rma.order.line', 'rma_id',
|
||||
string='RMA lines')
|
||||
in_shipment_count = fields.Integer(compute='_compute_in_shipment_count',
|
||||
string='# of Invoices')
|
||||
out_shipment_count = fields.Integer(compute='_compute_out_shipment_count',
|
||||
string='# of Outgoing Shipments')
|
||||
line_count = fields.Integer(compute='_compute_line_count',
|
||||
string='# of Outgoing Shipments')
|
||||
supplier_line_count = fields.Integer(
|
||||
compute='_compute_supplier_line_count',
|
||||
string='# of Supplier RMAs'
|
||||
comodel_name="res.partner", string="Partner", required=True
|
||||
)
|
||||
rma_line_ids = fields.One2many("rma.order.line", "rma_id", string="RMA lines")
|
||||
in_shipment_count = fields.Integer(
|
||||
compute="_compute_in_shipment_count", string="# of Invoices"
|
||||
)
|
||||
out_shipment_count = fields.Integer(
|
||||
compute="_compute_out_shipment_count", string="# of Outgoing Shipments"
|
||||
)
|
||||
line_count = fields.Integer(
|
||||
compute="_compute_line_count", string="# of Outgoing Shipments"
|
||||
)
|
||||
supplier_line_count = fields.Integer(
|
||||
compute="_compute_supplier_line_count", string="# of Supplier RMAs"
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
"res.company",
|
||||
string="Company",
|
||||
required=True,
|
||||
default=lambda self: self.env.user.company_id,
|
||||
)
|
||||
company_id = fields.Many2one('res.company', string='Company',
|
||||
required=True, default=lambda self:
|
||||
self.env.user.company_id)
|
||||
assigned_to = fields.Many2one(
|
||||
comodel_name='res.users', track_visibility='onchange',
|
||||
comodel_name="res.users",
|
||||
track_visibility="onchange",
|
||||
default=lambda self: self.env.uid,
|
||||
)
|
||||
requested_by = fields.Many2one(
|
||||
comodel_name='res.users', track_visibility='onchange',
|
||||
comodel_name="res.users",
|
||||
track_visibility="onchange",
|
||||
default=lambda self: self.env.uid,
|
||||
)
|
||||
in_warehouse_id = fields.Many2one(
|
||||
comodel_name='stock.warehouse',
|
||||
string='Inbound Warehouse',
|
||||
comodel_name="stock.warehouse",
|
||||
string="Inbound Warehouse",
|
||||
required=True,
|
||||
default=_default_warehouse_id,
|
||||
)
|
||||
customer_to_supplier = fields.Boolean(
|
||||
'The customer will send to the supplier',
|
||||
)
|
||||
supplier_to_customer = fields.Boolean(
|
||||
'The supplier will send to the customer',
|
||||
)
|
||||
customer_to_supplier = fields.Boolean("The customer will send to the supplier")
|
||||
supplier_to_customer = fields.Boolean("The supplier will send to the customer")
|
||||
supplier_address_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
string='Supplier Address',
|
||||
help="Address of the supplier in case of Customer RMA operation "
|
||||
"dropship.")
|
||||
comodel_name="res.partner",
|
||||
string="Supplier Address",
|
||||
help="Address of the supplier in case of Customer RMA operation " "dropship.",
|
||||
)
|
||||
customer_address_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
string='Customer Address',
|
||||
help="Address of the customer in case of Supplier RMA operation "
|
||||
"dropship.")
|
||||
comodel_name="res.partner",
|
||||
string="Customer Address",
|
||||
help="Address of the customer in case of Supplier RMA operation " "dropship.",
|
||||
)
|
||||
state = fields.Selection(
|
||||
compute=_compute_state,
|
||||
selection=[('draft', 'Draft'),
|
||||
('to_approve', 'To Approve'),
|
||||
('approved', 'Approved'),
|
||||
('done', 'Done')],
|
||||
string='State', default='draft', store=True
|
||||
selection=[
|
||||
("draft", "Draft"),
|
||||
("to_approve", "To Approve"),
|
||||
("approved", "Approved"),
|
||||
("done", "Done"),
|
||||
],
|
||||
string="State",
|
||||
default="draft",
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.constrains("partner_id", "rma_line_ids")
|
||||
def _check_partner_id(self):
|
||||
if self.rma_line_ids and self.partner_id != self.mapped(
|
||||
"rma_line_ids.partner_id"):
|
||||
raise UserError(_(
|
||||
"Group partner and RMA's partner must be the same."))
|
||||
"rma_line_ids.partner_id"
|
||||
):
|
||||
raise UserError(_("Group partner and RMA's partner must be the same."))
|
||||
if len(self.mapped("rma_line_ids.partner_id")) > 1:
|
||||
raise UserError(_(
|
||||
"All grouped RMA's should have same partner."))
|
||||
raise UserError(_("All grouped RMA's should have same partner."))
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if (self.env.context.get('supplier') or
|
||||
vals.get('type') == 'supplier'):
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||
'rma.order.supplier')
|
||||
if self.env.context.get("supplier") or vals.get("type") == "supplier":
|
||||
vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.supplier")
|
||||
else:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||
'rma.order.customer')
|
||||
vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.customer")
|
||||
return super(RmaOrder, self).create(vals)
|
||||
|
||||
@api.multi
|
||||
def action_view_in_shipments(self):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
action = self.env.ref("stock.action_picking_tree_all")
|
||||
result = action.read()[0]
|
||||
picking_ids = []
|
||||
for line in self.rma_line_ids:
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage == 'internal':
|
||||
if move.location_dest_id.usage == "internal":
|
||||
picking_ids.append(move.picking_id.id)
|
||||
else:
|
||||
if line.customer_to_supplier:
|
||||
@@ -191,32 +200,32 @@ class RmaOrder(models.Model):
|
||||
shipments = list(set(picking_ids))
|
||||
# choose the view_mode accordingly
|
||||
if len(shipments) > 1:
|
||||
result['domain'] = [('id', 'in', shipments)]
|
||||
result["domain"] = [("id", "in", shipments)]
|
||||
else:
|
||||
res = self.env.ref('stock.view_picking_form', False)
|
||||
result['views'] = [(res and res.id or False, 'form')]
|
||||
result['res_id'] = shipments[0]
|
||||
res = self.env.ref("stock.view_picking_form", False)
|
||||
result["views"] = [(res and res.id or False, "form")]
|
||||
result["res_id"] = shipments[0]
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def action_view_out_shipments(self):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
action = self.env.ref("stock.action_picking_tree_all")
|
||||
result = action.read()[0]
|
||||
picking_ids = []
|
||||
for line in self.rma_line_ids:
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage in ('supplier', 'customer'):
|
||||
if move.location_dest_id.usage in ("supplier", "customer"):
|
||||
if not line.customer_to_supplier:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
if picking_ids:
|
||||
shipments = list(set(picking_ids))
|
||||
# choose the view_mode accordingly
|
||||
if len(shipments) != 1:
|
||||
result['domain'] = [('id', 'in', shipments)]
|
||||
result["domain"] = [("id", "in", shipments)]
|
||||
else:
|
||||
res = self.env.ref('stock.view_picking_form', False)
|
||||
result['views'] = [(res and res.id or False, 'form')]
|
||||
result['res_id'] = shipments[0]
|
||||
res = self.env.ref("stock.view_picking_form", False)
|
||||
result["views"] = [(res and res.id or False, "form")]
|
||||
result["res_id"] = shipments[0]
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
@@ -228,56 +237,65 @@ class RmaOrder(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_view_lines(self):
|
||||
if self.type == 'customer':
|
||||
action = self.env.ref('rma.action_rma_customer_lines')
|
||||
res = self.env.ref('rma.view_rma_line_form', False)
|
||||
if self.type == "customer":
|
||||
action = self.env.ref("rma.action_rma_customer_lines")
|
||||
res = self.env.ref("rma.view_rma_line_form", False)
|
||||
else:
|
||||
action = self.env.ref('rma.action_rma_supplier_lines')
|
||||
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||
res = self.env.ref("rma.view_rma_line_supplier_form", False)
|
||||
result = action.read()[0]
|
||||
lines = self._get_valid_lines()
|
||||
# choose the view_mode accordingly
|
||||
if len(lines.ids) != 1:
|
||||
result['domain'] = [('id', 'in', lines.ids)]
|
||||
result["domain"] = [("id", "in", lines.ids)]
|
||||
else:
|
||||
result['views'] = [(res and res.id or False, 'form')]
|
||||
result['res_id'] = lines.id
|
||||
result['context'] = {}
|
||||
result["views"] = [(res and res.id or False, "form")]
|
||||
result["res_id"] = lines.id
|
||||
result["context"] = {}
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def action_view_supplier_lines(self):
|
||||
action = self.env.ref('rma.action_rma_supplier_lines')
|
||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||
result = action.read()[0]
|
||||
lines = self.rma_line_ids
|
||||
for line_id in lines:
|
||||
related_lines = [line.id for line in line_id.supplier_rma_line_ids]
|
||||
# choose the view_mode accordingly
|
||||
if len(related_lines) != 1:
|
||||
result['domain'] = [('id', 'in', related_lines)]
|
||||
result["domain"] = [("id", "in", related_lines)]
|
||||
else:
|
||||
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
||||
result['views'] = [(res and res.id or False, 'form')]
|
||||
result['res_id'] = related_lines[0]
|
||||
res = self.env.ref("rma.view_rma_line_supplier_form", False)
|
||||
result["views"] = [(res and res.id or False, "form")]
|
||||
result["res_id"] = related_lines[0]
|
||||
return result
|
||||
|
||||
@api.onchange('in_warehouse_id')
|
||||
@api.onchange("in_warehouse_id")
|
||||
def _onchange_in_warehouse_id(self):
|
||||
if self.in_warehouse_id and self.rma_line_ids:
|
||||
self.rma_line_ids.write(
|
||||
{'in_warehouse_id': self.in_warehouse_id.id,
|
||||
'location_id': self.in_warehouse_id.lot_rma_id.id})
|
||||
{
|
||||
"in_warehouse_id": self.in_warehouse_id.id,
|
||||
"location_id": self.in_warehouse_id.lot_rma_id.id,
|
||||
}
|
||||
)
|
||||
|
||||
@api.onchange('customer_to_supplier', 'supplier_address_id')
|
||||
@api.onchange("customer_to_supplier", "supplier_address_id")
|
||||
def _onchange_customer_to_supplier(self):
|
||||
if self.type == 'customer' and self.rma_line_ids:
|
||||
if self.type == "customer" and self.rma_line_ids:
|
||||
self.rma_line_ids.write(
|
||||
{'customer_to_supplier': self.customer_to_supplier,
|
||||
'supplier_address_id': self.supplier_address_id.id})
|
||||
{
|
||||
"customer_to_supplier": self.customer_to_supplier,
|
||||
"supplier_address_id": self.supplier_address_id.id,
|
||||
}
|
||||
)
|
||||
|
||||
@api.onchange('supplier_to_customer', 'customer_address_id')
|
||||
@api.onchange("supplier_to_customer", "customer_address_id")
|
||||
def _onchange_supplier_to_customer(self):
|
||||
if self.type == 'supplier' and self.rma_line_ids:
|
||||
if self.type == "supplier" and self.rma_line_ids:
|
||||
self.rma_line_ids.write(
|
||||
{'supplier_to_customer': self.supplier_to_customer,
|
||||
'customer_address_id': self.customer_address_id.id})
|
||||
{
|
||||
"supplier_to_customer": self.supplier_to_customer,
|
||||
"customer_address_id": self.customer_address_id.id,
|
||||
}
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,11 @@ class StockPicking(models.Model):
|
||||
res = super(StockPicking, self).action_assign()
|
||||
for picking in self:
|
||||
for move in picking.move_lines:
|
||||
if (move.rma_line_id and move.state == 'confirmed' and
|
||||
move.location_id.usage == 'customer'):
|
||||
if (
|
||||
move.rma_line_id
|
||||
and move.state == "confirmed"
|
||||
and move.location_id.usage == "customer"
|
||||
):
|
||||
move.force_assign()
|
||||
return res
|
||||
|
||||
@@ -24,15 +27,16 @@ class StockPicking(models.Model):
|
||||
class StockMove(models.Model):
|
||||
_inherit = "stock.move"
|
||||
|
||||
rma_line_id = fields.Many2one('rma.order.line', string='RMA line',
|
||||
ondelete='restrict')
|
||||
rma_line_id = fields.Many2one(
|
||||
"rma.order.line", string="RMA line", ondelete="restrict"
|
||||
)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('group_id'):
|
||||
group = self.env['procurement.group'].browse(vals['group_id'])
|
||||
if vals.get("group_id"):
|
||||
group = self.env["procurement.group"].browse(vals["group_id"])
|
||||
if group.rma_line_id:
|
||||
vals['rma_line_id'] = group.rma_line_id.id
|
||||
vals["rma_line_id"] = group.rma_line_id.id
|
||||
return super(StockMove, self).create(vals)
|
||||
|
||||
def _action_assign(self):
|
||||
|
||||
@@ -8,41 +8,37 @@ class StockWarehouse(models.Model):
|
||||
_inherit = "stock.warehouse"
|
||||
|
||||
lot_rma_id = fields.Many2one(
|
||||
comodel_name='stock.location', string='RMA Location',
|
||||
comodel_name="stock.location", string="RMA Location"
|
||||
) # not readonly to have the possibility to edit location and
|
||||
# propagate to rma rules (add a auto-update when writing this field?)
|
||||
rma_cust_out_type_id = fields.Many2one(
|
||||
comodel_name='stock.picking.type', string='RMA Customer out Type',
|
||||
readonly=True,
|
||||
comodel_name="stock.picking.type", string="RMA Customer out Type", readonly=True
|
||||
)
|
||||
rma_sup_out_type_id = fields.Many2one(
|
||||
comodel_name='stock.picking.type', string='RMA Supplier out Type',
|
||||
readonly=True,
|
||||
comodel_name="stock.picking.type", string="RMA Supplier out Type", readonly=True
|
||||
)
|
||||
rma_cust_in_type_id = fields.Many2one(
|
||||
comodel_name='stock.picking.type', string='RMA Customer in Type',
|
||||
readonly=True,
|
||||
comodel_name="stock.picking.type", string="RMA Customer in Type", readonly=True
|
||||
)
|
||||
rma_sup_in_type_id = fields.Many2one(
|
||||
comodel_name='stock.picking.type', string='RMA Supplier in Type',
|
||||
readonly=True,
|
||||
comodel_name="stock.picking.type", string="RMA Supplier in Type", readonly=True
|
||||
)
|
||||
rma_in_this_wh = fields.Boolean(
|
||||
string='RMA in this Warehouse',
|
||||
string="RMA in this Warehouse",
|
||||
help="If set, it will create RMA location, picking types and routes "
|
||||
"for this warehouse.",
|
||||
"for this warehouse.",
|
||||
)
|
||||
rma_customer_in_pull_id = fields.Many2one(
|
||||
comodel_name='stock.rule', string="RMA Customer In Rule",
|
||||
comodel_name="stock.rule", string="RMA Customer In Rule"
|
||||
)
|
||||
rma_customer_out_pull_id = fields.Many2one(
|
||||
comodel_name='stock.rule', string="RMA Customer Out Rule",
|
||||
comodel_name="stock.rule", string="RMA Customer Out Rule"
|
||||
)
|
||||
rma_supplier_in_pull_id = fields.Many2one(
|
||||
comodel_name='stock.rule', string="RMA Supplier In Rule",
|
||||
comodel_name="stock.rule", string="RMA Supplier In Rule"
|
||||
)
|
||||
rma_supplier_out_pull_id = fields.Many2one(
|
||||
comodel_name='stock.rule', string="RMA Supplier Out Rule",
|
||||
comodel_name="stock.rule", string="RMA Supplier Out Rule"
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@@ -51,7 +47,8 @@ class StockWarehouse(models.Model):
|
||||
self.rma_cust_out_type_id,
|
||||
self.rma_sup_out_type_id,
|
||||
self.rma_cust_in_type_id,
|
||||
self.rma_sup_in_type_id]
|
||||
self.rma_sup_in_type_id,
|
||||
]
|
||||
|
||||
@api.multi
|
||||
def _rma_types_available(self):
|
||||
@@ -64,17 +61,19 @@ class StockWarehouse(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if 'rma_in_this_wh' in vals:
|
||||
if "rma_in_this_wh" in vals:
|
||||
if vals.get("rma_in_this_wh"):
|
||||
for wh in self:
|
||||
# RMA location:
|
||||
if not wh.lot_rma_id:
|
||||
wh.lot_rma_id = self.env['stock.location'].create({
|
||||
'name': 'RMA',
|
||||
'usage': 'internal',
|
||||
'location_id': wh.lot_stock_id.id,
|
||||
'company_id': wh.company_id.id,
|
||||
})
|
||||
wh.lot_rma_id = self.env["stock.location"].create(
|
||||
{
|
||||
"name": "RMA",
|
||||
"usage": "internal",
|
||||
"location_id": wh.lot_stock_id.id,
|
||||
"company_id": wh.company_id.id,
|
||||
}
|
||||
)
|
||||
# RMA types
|
||||
if not wh._rma_types_available():
|
||||
wh._create_rma_picking_types()
|
||||
@@ -90,83 +89,89 @@ class StockWarehouse(models.Model):
|
||||
if type:
|
||||
type.active = False
|
||||
# Unlink rules:
|
||||
self.mapped('rma_customer_in_pull_id').unlink()
|
||||
self.mapped('rma_customer_out_pull_id').unlink()
|
||||
self.mapped('rma_supplier_in_pull_id').unlink()
|
||||
self.mapped('rma_supplier_out_pull_id').unlink()
|
||||
self.mapped("rma_customer_in_pull_id").unlink()
|
||||
self.mapped("rma_customer_out_pull_id").unlink()
|
||||
self.mapped("rma_supplier_in_pull_id").unlink()
|
||||
self.mapped("rma_supplier_out_pull_id").unlink()
|
||||
return super(StockWarehouse, self).write(vals)
|
||||
|
||||
def _create_rma_picking_types(self):
|
||||
picking_type_obj = self.env['stock.picking.type']
|
||||
picking_type_obj = self.env["stock.picking.type"]
|
||||
customer_loc, supplier_loc = self._get_partner_locations()
|
||||
for wh in self:
|
||||
other_pick_type = picking_type_obj.search(
|
||||
[('warehouse_id', '=', wh.id)], order='sequence desc',
|
||||
limit=1)
|
||||
[("warehouse_id", "=", wh.id)], order="sequence desc", limit=1
|
||||
)
|
||||
color = other_pick_type.color if other_pick_type else 0
|
||||
max_sequence = other_pick_type and other_pick_type.sequence or 0
|
||||
# create rma_cust_out_type_id:
|
||||
rma_cust_out_type_id = picking_type_obj.create({
|
||||
'name': _('Customer RMA Deliveries'),
|
||||
'warehouse_id': wh.id,
|
||||
'code': 'outgoing',
|
||||
'use_create_lots': True,
|
||||
'use_existing_lots': False,
|
||||
'sequence_id': self.env.ref(
|
||||
'rma.seq_picking_type_rma_cust_out').id,
|
||||
'default_location_src_id': wh.lot_rma_id.id,
|
||||
'default_location_dest_id': customer_loc.id,
|
||||
'sequence': max_sequence,
|
||||
'color': color,
|
||||
})
|
||||
rma_cust_out_type_id = picking_type_obj.create(
|
||||
{
|
||||
"name": _("Customer RMA Deliveries"),
|
||||
"warehouse_id": wh.id,
|
||||
"code": "outgoing",
|
||||
"use_create_lots": True,
|
||||
"use_existing_lots": False,
|
||||
"sequence_id": self.env.ref("rma.seq_picking_type_rma_cust_out").id,
|
||||
"default_location_src_id": wh.lot_rma_id.id,
|
||||
"default_location_dest_id": customer_loc.id,
|
||||
"sequence": max_sequence,
|
||||
"color": color,
|
||||
}
|
||||
)
|
||||
# create rma_sup_out_type_id:
|
||||
rma_sup_out_type_id = picking_type_obj.create({
|
||||
'name': _('Supplier RMA Deliveries'),
|
||||
'warehouse_id': wh.id,
|
||||
'code': 'outgoing',
|
||||
'use_create_lots': True,
|
||||
'use_existing_lots': False,
|
||||
'sequence_id': self.env.ref(
|
||||
'rma.seq_picking_type_rma_sup_out').id,
|
||||
'default_location_src_id': wh.lot_rma_id.id,
|
||||
'default_location_dest_id': supplier_loc.id,
|
||||
'sequence': max_sequence,
|
||||
'color': color,
|
||||
})
|
||||
rma_sup_out_type_id = picking_type_obj.create(
|
||||
{
|
||||
"name": _("Supplier RMA Deliveries"),
|
||||
"warehouse_id": wh.id,
|
||||
"code": "outgoing",
|
||||
"use_create_lots": True,
|
||||
"use_existing_lots": False,
|
||||
"sequence_id": self.env.ref("rma.seq_picking_type_rma_sup_out").id,
|
||||
"default_location_src_id": wh.lot_rma_id.id,
|
||||
"default_location_dest_id": supplier_loc.id,
|
||||
"sequence": max_sequence,
|
||||
"color": color,
|
||||
}
|
||||
)
|
||||
# create rma_cust_in_type_id:
|
||||
rma_cust_in_type_id = picking_type_obj.create({
|
||||
'name': _('Customer RMA Receipts'),
|
||||
'warehouse_id': wh.id,
|
||||
'code': 'incoming',
|
||||
'use_create_lots': True,
|
||||
'use_existing_lots': False,
|
||||
'sequence_id': self.env.ref(
|
||||
'rma.seq_picking_type_rma_cust_in').id,
|
||||
'default_location_src_id': customer_loc.id,
|
||||
'default_location_dest_id': wh.lot_rma_id.id,
|
||||
'sequence': max_sequence,
|
||||
'color': color,
|
||||
})
|
||||
rma_cust_in_type_id = picking_type_obj.create(
|
||||
{
|
||||
"name": _("Customer RMA Receipts"),
|
||||
"warehouse_id": wh.id,
|
||||
"code": "incoming",
|
||||
"use_create_lots": True,
|
||||
"use_existing_lots": False,
|
||||
"sequence_id": self.env.ref("rma.seq_picking_type_rma_cust_in").id,
|
||||
"default_location_src_id": customer_loc.id,
|
||||
"default_location_dest_id": wh.lot_rma_id.id,
|
||||
"sequence": max_sequence,
|
||||
"color": color,
|
||||
}
|
||||
)
|
||||
# create rma_sup_in_type_id:
|
||||
rma_sup_in_type_id = picking_type_obj.create({
|
||||
'name': _('Supplier RMA Receipts'),
|
||||
'warehouse_id': wh.id,
|
||||
'code': 'incoming',
|
||||
'use_create_lots': True,
|
||||
'use_existing_lots': False,
|
||||
'sequence_id': self.env.ref(
|
||||
'rma.seq_picking_type_rma_sup_in').id,
|
||||
'default_location_src_id': supplier_loc.id,
|
||||
'default_location_dest_id': wh.lot_rma_id.id,
|
||||
'sequence': max_sequence,
|
||||
'color': color,
|
||||
})
|
||||
wh.write({
|
||||
'rma_cust_out_type_id': rma_cust_out_type_id.id,
|
||||
'rma_sup_out_type_id': rma_sup_out_type_id.id,
|
||||
'rma_cust_in_type_id': rma_cust_in_type_id.id,
|
||||
'rma_sup_in_type_id': rma_sup_in_type_id.id,
|
||||
})
|
||||
rma_sup_in_type_id = picking_type_obj.create(
|
||||
{
|
||||
"name": _("Supplier RMA Receipts"),
|
||||
"warehouse_id": wh.id,
|
||||
"code": "incoming",
|
||||
"use_create_lots": True,
|
||||
"use_existing_lots": False,
|
||||
"sequence_id": self.env.ref("rma.seq_picking_type_rma_sup_in").id,
|
||||
"default_location_src_id": supplier_loc.id,
|
||||
"default_location_dest_id": wh.lot_rma_id.id,
|
||||
"sequence": max_sequence,
|
||||
"color": color,
|
||||
}
|
||||
)
|
||||
wh.write(
|
||||
{
|
||||
"rma_cust_out_type_id": rma_cust_out_type_id.id,
|
||||
"rma_sup_out_type_id": rma_sup_out_type_id.id,
|
||||
"rma_cust_in_type_id": rma_cust_in_type_id.id,
|
||||
"rma_sup_in_type_id": rma_sup_in_type_id.id,
|
||||
}
|
||||
)
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
@@ -174,93 +179,87 @@ class StockWarehouse(models.Model):
|
||||
self.ensure_one()
|
||||
rma_rules = dict()
|
||||
customer_loc, supplier_loc = self._get_partner_locations()
|
||||
rma_rules['rma_customer_in'] = {
|
||||
'name': self._format_rulename(self,
|
||||
customer_loc,
|
||||
self.lot_rma_id.name),
|
||||
'action': 'pull',
|
||||
'warehouse_id': self.id,
|
||||
'company_id': self.company_id.id,
|
||||
'location_src_id': customer_loc.id,
|
||||
'location_id': self.lot_rma_id.id,
|
||||
'procure_method': 'make_to_stock',
|
||||
'route_id': self.env.ref('rma.route_rma_customer').id,
|
||||
'picking_type_id': self.rma_cust_in_type_id.id,
|
||||
'active': True,
|
||||
rma_rules["rma_customer_in"] = {
|
||||
"name": self._format_rulename(self, customer_loc, self.lot_rma_id.name),
|
||||
"action": "pull",
|
||||
"warehouse_id": self.id,
|
||||
"company_id": self.company_id.id,
|
||||
"location_src_id": customer_loc.id,
|
||||
"location_id": self.lot_rma_id.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"route_id": self.env.ref("rma.route_rma_customer").id,
|
||||
"picking_type_id": self.rma_cust_in_type_id.id,
|
||||
"active": True,
|
||||
}
|
||||
rma_rules['rma_customer_out'] = {
|
||||
'name': self._format_rulename(self,
|
||||
self.lot_rma_id,
|
||||
customer_loc.name),
|
||||
'action': 'pull',
|
||||
'warehouse_id': self.id,
|
||||
'company_id': self.company_id.id,
|
||||
'location_src_id': self.lot_rma_id.id,
|
||||
'location_id': customer_loc.id,
|
||||
'procure_method': 'make_to_stock',
|
||||
'route_id': self.env.ref('rma.route_rma_customer').id,
|
||||
'picking_type_id': self.rma_cust_out_type_id.id,
|
||||
'active': True,
|
||||
rma_rules["rma_customer_out"] = {
|
||||
"name": self._format_rulename(self, self.lot_rma_id, customer_loc.name),
|
||||
"action": "pull",
|
||||
"warehouse_id": self.id,
|
||||
"company_id": self.company_id.id,
|
||||
"location_src_id": self.lot_rma_id.id,
|
||||
"location_id": customer_loc.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"route_id": self.env.ref("rma.route_rma_customer").id,
|
||||
"picking_type_id": self.rma_cust_out_type_id.id,
|
||||
"active": True,
|
||||
}
|
||||
rma_rules['rma_supplier_in'] = {
|
||||
'name': self._format_rulename(self,
|
||||
supplier_loc,
|
||||
self.lot_rma_id.name),
|
||||
'action': 'pull',
|
||||
'warehouse_id': self.id,
|
||||
'company_id': self.company_id.id,
|
||||
'location_src_id': supplier_loc.id,
|
||||
'location_id': self.lot_rma_id.id,
|
||||
'procure_method': 'make_to_stock',
|
||||
'route_id': self.env.ref('rma.route_rma_supplier').id,
|
||||
'picking_type_id': self.rma_sup_in_type_id.id,
|
||||
'active': True,
|
||||
rma_rules["rma_supplier_in"] = {
|
||||
"name": self._format_rulename(self, supplier_loc, self.lot_rma_id.name),
|
||||
"action": "pull",
|
||||
"warehouse_id": self.id,
|
||||
"company_id": self.company_id.id,
|
||||
"location_src_id": supplier_loc.id,
|
||||
"location_id": self.lot_rma_id.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"route_id": self.env.ref("rma.route_rma_supplier").id,
|
||||
"picking_type_id": self.rma_sup_in_type_id.id,
|
||||
"active": True,
|
||||
}
|
||||
rma_rules['rma_supplier_out'] = {
|
||||
'name': self._format_rulename(self,
|
||||
self.lot_rma_id,
|
||||
supplier_loc.name),
|
||||
'action': 'pull',
|
||||
'warehouse_id': self.id,
|
||||
'company_id': self.company_id.id,
|
||||
'location_src_id': self.lot_rma_id.id,
|
||||
'location_id': supplier_loc.id,
|
||||
'procure_method': 'make_to_stock',
|
||||
'route_id': self.env.ref('rma.route_rma_supplier').id,
|
||||
'picking_type_id': self.rma_sup_out_type_id.id,
|
||||
'active': True,
|
||||
rma_rules["rma_supplier_out"] = {
|
||||
"name": self._format_rulename(self, self.lot_rma_id, supplier_loc.name),
|
||||
"action": "pull",
|
||||
"warehouse_id": self.id,
|
||||
"company_id": self.company_id.id,
|
||||
"location_src_id": self.lot_rma_id.id,
|
||||
"location_id": supplier_loc.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"route_id": self.env.ref("rma.route_rma_supplier").id,
|
||||
"picking_type_id": self.rma_sup_out_type_id.id,
|
||||
"active": True,
|
||||
}
|
||||
return rma_rules
|
||||
|
||||
def _create_or_update_rma_pull(self):
|
||||
rule_obj = self.env['stock.rule']
|
||||
rule_obj = self.env["stock.rule"]
|
||||
for wh in self:
|
||||
rules_dict = wh.get_rma_rules_dict()
|
||||
if wh.rma_customer_in_pull_id:
|
||||
wh.rma_customer_in_pull_id.write(rules_dict['rma_customer_in'])
|
||||
wh.rma_customer_in_pull_id.write(rules_dict["rma_customer_in"])
|
||||
else:
|
||||
wh.rma_customer_in_pull_id = rule_obj.create(
|
||||
rules_dict['rma_customer_in'])
|
||||
rules_dict["rma_customer_in"]
|
||||
)
|
||||
|
||||
if wh.rma_customer_out_pull_id:
|
||||
wh.rma_customer_out_pull_id.write(
|
||||
rules_dict['rma_customer_out'])
|
||||
wh.rma_customer_out_pull_id.write(rules_dict["rma_customer_out"])
|
||||
else:
|
||||
wh.rma_customer_out_pull_id = rule_obj.create(
|
||||
rules_dict['rma_customer_out'])
|
||||
rules_dict["rma_customer_out"]
|
||||
)
|
||||
|
||||
if wh.rma_supplier_in_pull_id:
|
||||
wh.rma_supplier_in_pull_id.write(rules_dict['rma_supplier_in'])
|
||||
wh.rma_supplier_in_pull_id.write(rules_dict["rma_supplier_in"])
|
||||
else:
|
||||
wh.rma_supplier_in_pull_id = rule_obj.create(
|
||||
rules_dict['rma_supplier_in'])
|
||||
rules_dict["rma_supplier_in"]
|
||||
)
|
||||
|
||||
if wh.rma_supplier_out_pull_id:
|
||||
wh.rma_supplier_out_pull_id.write(
|
||||
rules_dict['rma_supplier_out'])
|
||||
wh.rma_supplier_out_pull_id.write(rules_dict["rma_supplier_out"])
|
||||
else:
|
||||
wh.rma_supplier_out_pull_id = rule_obj.create(
|
||||
rules_dict['rma_supplier_out'])
|
||||
rules_dict["rma_supplier_out"]
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user