update stock_barcode

This commit is contained in:
ivan deng
2018-07-06 20:04:46 +08:00
parent a99ebdad06
commit e28cc0b382
12 changed files with 178 additions and 511 deletions

View File

@@ -13,34 +13,36 @@ class Picking(models.Model):
_name = 'stock.picking'
_inherit = ['stock.picking', 'barcodes.barcode_events_mixin']
# 是否在扫码视图
# 是否在扫码视图,暂时不用,使用原生方式处理
is_barcode_view = fields.Boolean('Barcode view', defult=False)
# 扫码摘要
header_title = fields.Char('Briefing', compute='_compute_briefing')
# 作业,已扫码未装入包操作的记录行
pack_operation_product_current_ids = fields.One2many(
'stock.pack.current', 'picking_id', string='Product packing', readonly=True, copy=False)
'stock.pack.operation', 'picking_id', string='Product packing',
compute='_compute_product_current', readonly=True, copy=False)
# 作业,已装入包操作的散件
pack_operation_product_packed_ids = fields.One2many(
'stock.pack.operation', 'picking_id', 'Product packed',
'stock.pack.operation', 'picking_id', string='Product packed',
domain=[('product_id', '>=', 1), ('qty_done', '>=', 1), ('result_package_id', '!=', False)], readonly=True, copy=False)
# 散件涉及到的包裹列表
result_package_ids = fields.Many2many('stock.quant.package', string='Result Packages', readonly=True, copy=False)
# 当前操作产品
last_op_product = fields.Many2one('product.product', string='Last OP', readonly=True)
# 上次操作产品
last_op_product = fields.Many2one('product.product', string='Last OP', readonly=True, copy=False)
# 上次打包的包裹,用于批量克隆
last_op_package = fields.Many2one('stock.quant.package', string='Last Package', readonly=True, copy=False)
# 待办统计,散件与包裹一起处理的数量
product_qty_total = fields.Float('To Do Total', compute="_compute_product_qty_total",
digits=dp.get_precision('Product Unit of Measure'), readonly=True, store=True) # 总待办数量
package_count = fields.Integer('Package Total', compute="_compute_package_count", readonly=True) # 待处理的包裹数量
# 完成统计,验证后才有
qty_done_total = fields.Float('Done Total', compute="_compute_done_total",
digits=dp.get_precision('Product Unit of Measure'), readonly=True, store=True) # 总完成数量
digits=dp.get_precision('Product Unit of Measure'), readonly=True, store=True, copy=False) # 总完成数量
weight_done_total = fields.Float('Weight Done Total(kg)', digits=dp.get_precision('Stock Weight'),
compute="_compute_done_total", readonly=True, store=True) # 总完成重量
package_count = fields.Integer('Package Total', compute="_compute_package_count", readonly=True) # 处理的包裹数量
package_done_count = fields.Integer('Package Done Total', compute="_compute_package_done_count", readonly=True, store=True) # 已处理的包裹数量
result_package_count = fields.Integer('Result Package Total', compute="_compute_package_done_count", readonly=True, store=True) # 放入的包裹数量
compute="_compute_done_total", readonly=True, store=True, copy=False) # 总完成重量
package_done_count = fields.Integer('Package Done Total', compute="_compute_package_done_count", readonly=True, store=True, copy=False) # 处理的包裹数量
result_package_count = fields.Integer('Result Package Total', compute="_compute_package_done_count", readonly=True, store=True, copy=False) # 放入的包裹数量
@api.depends('partner_id')
def _compute_briefing(self):
@@ -80,8 +82,8 @@ class Picking(models.Model):
rec.qty_done_total = qty_done_total
rec.weight_done_total = weight_done_total
@api.multi
@api.depends('pack_operation_product_ids.result_package_id', 'pack_operation_pack_ids')
@api.one
def _compute_package_count(self):
for rec in self:
# 散件打包数量
@@ -89,8 +91,8 @@ class Picking(models.Model):
# 包裹再打包数量
rec.package_count += len(rec.pack_operation_pack_ids)
@api.multi
@api.depends('state', 'pack_operation_product_ids.result_package_id', 'pack_operation_pack_ids.result_package_id')
@api.one
def _compute_package_done_count(self):
for rec in self:
if rec.state == 'done':
@@ -99,48 +101,30 @@ class Picking(models.Model):
rec.package_done_count += len(pack_packs.mapped('result_package_id').ids) + rec.result_package_count
# 不用于字段compute在每次放入包裹操作执行重新计算
def set_package(self):
# 设置上次打包的包裹
@api.multi
def set_package(self, pack):
for rec in self:
if pack:
rec.last_op_package = pack
if rec.pack_operation_product_packed_ids:
rec.result_package_ids = rec.pack_operation_product_ids.mapped('result_package_id').ids
rec.package_count = len(rec.result_package_ids) + len(rec.pack_operation_pack_ids)
pass
@api.multi
def put_in_pack2(self):
self.put_in_pack()
@api.multi
def put_in_pack(self):
pack = super(Picking, self).put_in_pack()
self.set_package()
self.set_current()
self.set_package(pack)
return pack
# 每次重新算todo: 只更新相关行
@api.onchange('pack_operation_product_ids')
def set_current(self):
self.pack_operation_product_current_ids = [(5, 0, 0)]
current_ids = []
if self.pack_operation_product_ids and self.state != 'done':
current_ids = self.pack_operation_product_ids \
.filtered(lambda pack: pack.product_id and pack.qty_done > 0 and not pack.result_package_id)
if current_ids:
ops = []
for op in current_ids:
ops.insert(0, [0, 0, {
'picking_id': self.id,
'product_id': op.product_id.id,
'product_uom_id': op.product_uom_id.id,
'product_qty': op.product_qty,
'qty_done': op.qty_done,
'weight': op.weight,
}])
self.update({'pack_operation_product_current_ids': ops})
def _check_product(self, product, qty=1.0):
self.last_op_product = product
return super(Picking, self)._check_product(product, qty)
@api.multi
@api.depends('pack_operation_product_ids.qty_done', 'state')
def _compute_product_current(self):
for op in self:
if op.pack_operation_product_ids and op.state == 'assigned':
op.pack_operation_product_current_ids = op.pack_operation_product_ids.filtered(
lambda x: x.product_id and x.qty_done >= 1 and not x.result_package_id)
def action_see_packages(self):
self.ensure_one()
@@ -149,3 +133,4 @@ class Picking(models.Model):
packages += self.pack_operation_pack_ids.mapped('result_package_id')
action['domain'] = [('id', 'in', packages.ids)]
return action