diff --git a/stock_batch_picking_ux/__manifest__.py b/stock_batch_picking_ux/__manifest__.py
index f0a4c64a3..b52e6f3ec 100644
--- a/stock_batch_picking_ux/__manifest__.py
+++ b/stock_batch_picking_ux/__manifest__.py
@@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Stock Usability with Batch Picking and stock vouchers',
- 'version': '12.0.1.0.0',
+ 'version': '13.0.1.0.0',
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
@@ -31,9 +31,10 @@
'depends': [
'stock_ux',
'stock_voucher',
- 'stock_batch_picking',
+ 'stock_picking_batch_extended',
],
'data': [
+ 'data/stock_batch_picking_data.xml',
'views/stock_batch_picking_views.xml',
'views/stock_move_line_views.xml',
'views/stock_picking_views.xml',
@@ -41,7 +42,7 @@
],
'demo': [
],
- 'installable': False,
+ 'installable': True,
'auto_install': True,
'application': False,
}
diff --git a/stock_batch_picking_ux/data/stock_batch_picking_data.xml b/stock_batch_picking_ux/data/stock_batch_picking_data.xml
new file mode 100644
index 000000000..1f3dc58cc
--- /dev/null
+++ b/stock_batch_picking_ux/data/stock_batch_picking_data.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/stock_batch_picking_ux/models/stock_batch_picking.py b/stock_batch_picking_ux/models/stock_batch_picking.py
index 22e02c8b0..f4eeee829 100644
--- a/stock_batch_picking_ux/models/stock_batch_picking.py
+++ b/stock_batch_picking_ux/models/stock_batch_picking.py
@@ -6,9 +6,9 @@
from odoo.exceptions import UserError
-class StockBatchPicking(models.Model):
+class StockPickingBatch(models.Model):
- _inherit = 'stock.batch.picking'
+ _inherit = 'stock.picking.batch'
# operation_type = fields.Selection([
# ('incoming', 'Suppliers'),
@@ -69,17 +69,7 @@ class StockBatchPicking(models.Model):
)
vouchers = fields.Char(
related='picking_ids.vouchers',
- readonly=True,
)
- # do this because if not allow to set the qty_done value in sml in
- # the tree view
- move_line_ids = fields.One2many(
- 'stock.move.line',
- inverse='_inverse_move_line_ids'
- )
-
- def _inverse_move_line_ids(self):
- pass
# overwrite this because we need only takes the moves with are not cancel
@api.depends('picking_ids')
@@ -94,12 +84,14 @@ def _compute_picking_type_data(self):
types = rec.picking_ids.mapped('picking_type_id')
rec.picking_type_ids = types
rec.voucher_required = any(x.voucher_required for x in types)
+ rec.restrict_number_package = False
# este viene exigido desde la cia pero seguramente lo movamos a
# exigir desde picking type
# solo es requerido para outgoings
if rec.picking_code == 'outgoing':
rec.restrict_number_package = any(
- x.restrict_number_package for x in rec.picking_ids)
+ x.picking_type_id.restrict_number_package
+ for x in rec.picking_ids)
# TODO deberiamos ver como hacer para aceptar multiples numeros de remitos
# si llega a ser necesario
# voucher_ids = fields.One2many(
@@ -112,34 +104,28 @@ def _compute_picking_type_data(self):
# compute='_compute_vouchers'
# )
- # @api.multi
- # @api.depends('voucher_ids.display_name')
- # def _compute_vouchers(self):
- # for rec in self:
- # rec.vouchers = ', '.join(rec.mapped('voucher_ids.display_name'))
-
# @api.onchange('picking_type_id', 'partner_id')
@api.onchange('picking_code', 'partner_id')
def changes_set_pickings(self):
# if we change type or partner reset pickings
self.picking_ids = False
- # @api.constrains('voucher_number', 'picking_type_id')
@api.onchange('voucher_number', 'picking_ids')
- @api.constrains('voucher_number', 'picking_ids')
def format_voucher_number(self):
for rec in self:
- # TODO, mejorarlo, por ahora tomamos un solo validador
- validators = rec.picking_type_ids.mapped(
- 'voucher_number_validator_id')
- if not validators:
+ if not rec.voucher_number:
continue
- voucher_number = validators[0].validate_value(
- rec.voucher_number)
+ voucher_number = self.env['stock.picking.voucher']._format_document_number(rec.voucher_number)
if voucher_number and voucher_number != rec.voucher_number:
rec.voucher_number = voucher_number
- @api.multi
+ def write(self, vals):
+ if 'voucher_number' in vals and vals.get('voucher_number'):
+ voucher_number = self.env['stock.picking.voucher']._format_document_number(vals.get('voucher_number'))
+ if voucher_number and voucher_number != vals.get('voucher_number'):
+ vals['voucher_number'] = voucher_number
+ return super().write(vals)
+
def add_picking_operation(self):
self.ensure_one()
view_id = self.env.ref('stock_ux.view_move_line_tree').id
@@ -154,7 +140,6 @@ def add_picking_operation(self):
"context": {"create": False, "from_batch": True},
}
- @api.multi
def action_transfer(self):
# agregamos los numeros de remito
for rec in self:
@@ -191,11 +176,11 @@ def action_transfer(self):
# con do_new_transfer
rec.active_picking_ids.do_stock_voucher_transfer_check()
- res = super(StockBatchPicking, self.with_context(
+ res = super(StockPickingBatch, self.with_context(
do_not_assign_numbers=True)).action_transfer()
# nosotros preferimos que no se haga en muchos pasos y una vez
# confirmado se borre lo no hecho y se marque como realizado
# lo hago para distinto de incomring porque venia andando bien para
# Incoming, pero no debería hacer falta este chequeo
- self.remove_undone_pickings()
+ # self.remove_undone_pickings()
return res
diff --git a/stock_batch_picking_ux/models/stock_move_line.py b/stock_batch_picking_ux/models/stock_move_line.py
index 87a5979bb..483787189 100644
--- a/stock_batch_picking_ux/models/stock_move_line.py
+++ b/stock_batch_picking_ux/models/stock_move_line.py
@@ -11,7 +11,6 @@ class StockMoveLine(models.Model):
origin = fields.Char(
related='move_id.picking_id.origin',
- readonly=True,
# we store so we can group
store=True,
)
diff --git a/stock_batch_picking_ux/models/stock_picking.py b/stock_batch_picking_ux/models/stock_picking.py
index 8ab3304f5..90e1d4cc5 100644
--- a/stock_batch_picking_ux/models/stock_picking.py
+++ b/stock_batch_picking_ux/models/stock_picking.py
@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
+from odoo.tools import float_is_zero
class StockPicking(models.Model):
@@ -33,15 +34,17 @@ def force_transfer(self, force_qty=True):
for pack in pick.move_line_ids:
pack.qty_done = pack.product_uom_qty
else:
- if all(pack.qty_done == 0 for pack in pick.move_line_ids):
+ if all(
+ float_is_zero(
+ pack.qty_done,
+ precision_rounding=pack.product_uom_id.rounding)
+ for pack in pick.move_line_ids):
# No qties to process, release out of the batch
- pick.batch_picking_id = False
+ pick.batch_id = False
continue
else:
for pack in pick.move_line_ids:
if not pack.qty_done:
pack.unlink()
- else:
- pack.product_uom_qty = pack.qty_done
pick.do_transfer()
diff --git a/stock_batch_picking_ux/models/stock_picking_voucher.py b/stock_batch_picking_ux/models/stock_picking_voucher.py
index 407397f69..aae433cc7 100644
--- a/stock_batch_picking_ux/models/stock_picking_voucher.py
+++ b/stock_batch_picking_ux/models/stock_picking_voucher.py
@@ -2,27 +2,26 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
-from odoo import models, api, _
+from odoo import models, _
from odoo.exceptions import ValidationError
class StockPickingVoucher(models.Model):
_inherit = 'stock.picking.voucher'
- @api.multi
def _check_voucher_number_unique(self):
"""
We modify it to make it unique per batch (if available) or per
pikcing
"""
self.ensure_one()
- if self.picking_id.batch_picking_id:
+ if self.picking_id.batch_id:
same_number_recs = self.search([
('picking_id.partner_id', '=',
self.picking_id.partner_id.id),
('name', '=', self.name),
- ('picking_id.batch_picking_id', '!=',
- self.picking_id.batch_picking_id.id),
+ ('picking_id.batch_id', '!=',
+ self.picking_id.batch_id.id),
('id', '!=', self.id),
])
if same_number_recs:
@@ -31,5 +30,4 @@ def _check_voucher_number_unique(self):
'partner'))
else:
- return super(
- StockPickingVoucher, self)._check_voucher_number_unique()
+ return super()._check_voucher_number_unique()
diff --git a/stock_batch_picking_ux/views/stock_batch_picking_views.xml b/stock_batch_picking_ux/views/stock_batch_picking_views.xml
index 0d815c53f..623bd8fdc 100644
--- a/stock_batch_picking_ux/views/stock_batch_picking_views.xml
+++ b/stock_batch_picking_ux/views/stock_batch_picking_views.xml
@@ -1,10 +1,10 @@
-
+
- stock.batch.picking.form
- stock.batch.picking
-
+ stock.picking.batch.form
+ stock.picking.batch
+
@@ -19,11 +19,11 @@
-
+
- stock.batch.picking.form
- stock.batch.picking
-
+ stock.picking.batch.form
+ stock.picking.batch
+
@@ -34,11 +34,11 @@
-
+
- stock.batch.picking.form
- stock.batch.picking
-
+ stock.picking.batch.form
+ stock.picking.batch
+
@@ -47,7 +47,7 @@
@@ -55,14 +55,15 @@
-
+
-
+
+
@@ -71,7 +72,7 @@
{'show_print_button': 1}
- [('partner_id', '=', partner_id), ('picking_type_id.code', '=', picking_code), ('state', 'in', ('confirmed', 'partially_available', 'assigned'))]
+ [('company_id', '=', company_id), ('partner_id', '=', partner_id), ('picking_type_id.code', '=', picking_code), ('state', 'in', ('confirmed', 'partially_available', 'assigned'))]
@@ -96,7 +97,6 @@
-
diff --git a/stock_batch_picking_ux/views/stock_move_line_views.xml b/stock_batch_picking_ux/views/stock_move_line_views.xml
index 161ffdc48..8714c06d9 100755
--- a/stock_batch_picking_ux/views/stock_move_line_views.xml
+++ b/stock_batch_picking_ux/views/stock_move_line_views.xml
@@ -28,7 +28,7 @@
context.get('from_batch')
-
+
diff --git a/stock_voucher/models/stock_picking_voucher.py b/stock_voucher/models/stock_picking_voucher.py
index 31651a9fa..ac3b1905d 100644
--- a/stock_voucher/models/stock_picking_voucher.py
+++ b/stock_voucher/models/stock_picking_voucher.py
@@ -69,6 +69,8 @@ def _format_document_number(self, document_number):
'The document number must be entered with a dash (-) and a maximum of 4 characters for the first part'
'and 8 for the second. The following are examples of valid numbers:\n* 1-1\n* 0001-00000001'
'\n')))
+ else:
+ return document_number
@api.constrains('name', 'picking_id')
@api.onchange('name', 'picking_id')