mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX]action view shipments and count
This commit is contained in:
@@ -99,17 +99,10 @@ class RmaOrder(models.Model):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
result = action.read()[0]
|
||||
picking_ids = []
|
||||
suppliers = self.env.ref('stock.stock_location_suppliers')
|
||||
customers = self.env.ref('stock.stock_location_customers')
|
||||
for line in self.rma_line_ids:
|
||||
if line.type == 'customer':
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id == customers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
else:
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id == suppliers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage == 'internal':
|
||||
picking_ids.append(move.picking_id.id)
|
||||
shipments = list(set(picking_ids))
|
||||
# choose the view_mode accordingly
|
||||
if len(shipments) != 1:
|
||||
@@ -126,17 +119,10 @@ class RmaOrder(models.Model):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
result = action.read()[0]
|
||||
picking_ids = []
|
||||
suppliers = self.env.ref('stock.stock_location_suppliers')
|
||||
customers = self.env.ref('stock.stock_location_customers')
|
||||
for line in self.rma_line_ids:
|
||||
if line.type == 'customer':
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id != customers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
else:
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id != suppliers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage in ('supplier', 'customer'):
|
||||
picking_ids.append(move.picking_id.id)
|
||||
shipments = list(set(picking_ids))
|
||||
# choose the view_mode accordingly
|
||||
if len(shipments) != 1:
|
||||
|
||||
@@ -47,7 +47,7 @@ class RmaOrderLine(models.Model):
|
||||
@api.multi
|
||||
def _compute_in_shipment_count(self):
|
||||
for line in self:
|
||||
moves = line.procurement_ids.mapped('move_ids').filtered(
|
||||
moves = line.mapped('move_ids').filtered(
|
||||
lambda m: m.location_dest_id.usage == 'internal' and
|
||||
m.state != 'cancel')
|
||||
pickings = moves.mapped('picking_id')
|
||||
@@ -56,7 +56,7 @@ class RmaOrderLine(models.Model):
|
||||
@api.multi
|
||||
def _compute_out_shipment_count(self):
|
||||
for line in self:
|
||||
moves = line.procurement_ids.mapped('move_ids').filtered(
|
||||
moves = line.mapped('move_ids').filtered(
|
||||
lambda m: m.location_dest_id.usage != 'internal' and
|
||||
m.state != 'cancel')
|
||||
pickings = moves.mapped('picking_id')
|
||||
@@ -213,7 +213,7 @@ class RmaOrderLine(models.Model):
|
||||
readonly=True, states={"new": [("readonly", False)]},
|
||||
)
|
||||
product_qty = fields.Float(
|
||||
string='Ordered Qty', copy=False, default=1.0,
|
||||
string='Ordered Qty', copy=False,
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
)
|
||||
@@ -227,12 +227,11 @@ class RmaOrderLine(models.Model):
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
)
|
||||
procurement_count = fields.Integer(compute=_compute_procurement_count,
|
||||
string='# of Procurements', copy=False,
|
||||
default=0)
|
||||
string='# of Procurements', copy=False)
|
||||
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
|
||||
string='# of Shipments', default=0)
|
||||
string='# of Shipments')
|
||||
out_shipment_count = fields.Integer(compute=_compute_out_shipment_count,
|
||||
string='# of Deliveries', default=0)
|
||||
string='# of Deliveries')
|
||||
move_ids = fields.One2many('stock.move', 'rma_line_id',
|
||||
string='Stock Moves', readonly=True,
|
||||
copy=False)
|
||||
@@ -549,17 +548,10 @@ class RmaOrderLine(models.Model):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
result = action.read()[0]
|
||||
picking_ids = []
|
||||
suppliers = self.env.ref('stock.stock_location_suppliers')
|
||||
customers = self.env.ref('stock.stock_location_customers')
|
||||
for line in self:
|
||||
if line.type == 'customer':
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id == customers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
else:
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id == suppliers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage == 'internal':
|
||||
picking_ids.append(move.picking_id.id)
|
||||
shipments = list(set(picking_ids))
|
||||
# choose the view_mode accordingly
|
||||
if len(shipments) != 1:
|
||||
@@ -576,17 +568,10 @@ class RmaOrderLine(models.Model):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
result = action.read()[0]
|
||||
picking_ids = []
|
||||
suppliers = self.env.ref('stock.stock_location_suppliers')
|
||||
customers = self.env.ref('stock.stock_location_customers')
|
||||
for line in self:
|
||||
if line.type == 'customer':
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id != customers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
else:
|
||||
for move in line.move_ids:
|
||||
if move.picking_id.location_id != suppliers:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
for move in line.move_ids:
|
||||
if move.location_dest_id.usage in ('supplier', 'customer'):
|
||||
picking_ids.append(move.picking_id.id)
|
||||
shipments = list(set(picking_ids))
|
||||
# choose the view_mode accordingly
|
||||
if len(shipments) != 1:
|
||||
|
||||
Reference in New Issue
Block a user