Skip to content

Commit

Permalink
Merge 902ead6 into b872e20
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomacr committed Feb 9, 2021
2 parents b872e20 + 902ead6 commit a86c2b6
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 64 deletions.
7 changes: 4 additions & 3 deletions stock_batch_picking_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '',
Expand All @@ -31,17 +31,18 @@
'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',
'report/batch_picking_list_data.xml',
],
'demo': [
],
'installable': False,
'installable': True,
'auto_install': True,
'application': False,
}
7 changes: 7 additions & 0 deletions stock_batch_picking_ux/data/stock_batch_picking_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<function model="res.company" name="write">
<value model="res.company" eval="obj().search([]).ids"/>
<value model="res.company" eval="{'use_oca_batch_validation': True}"/>
</function>
</odoo>
47 changes: 16 additions & 31 deletions stock_batch_picking_ux/models/stock_batch_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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')
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion stock_batch_picking_ux/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
11 changes: 7 additions & 4 deletions stock_batch_picking_ux/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
12 changes: 5 additions & 7 deletions stock_batch_picking_ux/models/stock_picking_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
34 changes: 17 additions & 17 deletions stock_batch_picking_ux/views/stock_batch_picking_views.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<odoo>

<!-- stock.batch.picking tree view -->
<!-- stock.picking.batch tree view -->
<record model="ir.ui.view" id="stock_batch_picking_search">
<field name="name">stock.batch.picking.form</field>
<field name="model">stock.batch.picking</field>
<field name="inherit_id" ref="stock_batch_picking.stock_batch_picking_search"/>
<field name="name">stock.picking.batch.form</field>
<field name="model">stock.picking.batch</field>
<field name="inherit_id" ref="stock_picking_batch_extended.stock_batch_picking_search"/>
<field name="arch" type="xml">
<field name="name" position="after">
<!-- al buscar por picking busca por nro de remto -->
Expand All @@ -19,11 +19,11 @@
</field>
</record>

<!-- stock.batch.picking tree view -->
<!-- stock.picking.batch tree view -->
<record model="ir.ui.view" id="stock_batch_picking_tree">
<field name="name">stock.batch.picking.form</field>
<field name="model">stock.batch.picking</field>
<field name="inherit_id" ref="stock_batch_picking.stock_batch_picking_tree"/>
<field name="name">stock.picking.batch.form</field>
<field name="model">stock.picking.batch</field>
<field name="inherit_id" ref="stock_picking_batch_extended.stock_batch_picking_tree"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="vouchers"/>
Expand All @@ -34,11 +34,11 @@
</field>
</record>

<!-- stock.batch.picking form view -->
<!-- stock.picking.batch form view -->
<record model="ir.ui.view" id="stock_batch_picking_form">
<field name="name">stock.batch.picking.form</field>
<field name="model">stock.batch.picking</field>
<field name="inherit_id" ref="stock_batch_picking.stock_batch_picking_form"/>
<field name="name">stock.picking.batch.form</field>
<field name="model">stock.picking.batch</field>
<field name="inherit_id" ref="stock_picking_batch_extended.stock_batch_picking_form"/>
<field name="arch" type="xml">

<!-- hacemos este boton invisible porque para recepciones no tiene sentido y, si se confirma y cambia de estado no se pueden agregar mas pickings y luego el usuario se puede tentar en cancelar en cuyo caso se cancelan los pickings tambien -->
Expand All @@ -47,22 +47,23 @@
</button>

<button name="action_cancel" position="attributes">
<attribute name="groups">stock_usability.allow_picking_cancellation</attribute>
<attribute name="groups">stock_ux.allow_picking_cancellation</attribute>
<attribute name="confirm">ATENCION! Al cancelar un picking batch todos los pickings relacionados también se van a cancelar. Seguro desea continuar?</attribute>
</button>

<field name="name" position="after">
<button name="add_picking_operation" class="oe_inline oe_right" type="object" string="Process Operations" attrs="{'invisible': [('state', 'in', ['cancel', 'done'])]}"/>
</field>

<field name="picker_id" position="before">
<field name="user_id" position="before">
<field name="picking_code" invisible="1"/>
<field name="voucher_required" invisible="1"/>
<field name="picking_code"/>
<!-- <field name="picking_type_id"/> -->
<!-- al final lo sacamos porque ya lo estamos usando para otros tipos -->
<!-- como por ahora solo lo usamos para entrada lo restringimos -->
<field name="partner_id" context="{'default_supplier': picking_code == 'incoming', 'default_customer': picking_code == 'outgoing'}" domain="picking_code == 'incoming' and ['|', ('parent_id.supplier', '=', True), ('supplier', '=', True)] or picking_code == 'outgoing' and ['|', ('parent_id.customer', '=', True), ('customer', '=', True)] or []"/>
<field name="partner_id" context="{'res_partner_search_mode': picking_code == 'incoming' and 'supplier' or 'customer'}"/>
<field name="company_id" groups="base.group_multi_company" attrs="{'readonly': [('picking_ids', '!=', [])]}" force_save="1"/>
<!-- <field name="partner_id" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0}" domain="[('supplier','=',True)]"/> -->
<field name="voucher_number" attrs="{'invisible': [('picking_code','!=','incoming')], 'required': [('voucher_required','=',True)]}"/>
<field name="number_of_packages"/>
Expand All @@ -71,7 +72,7 @@

<field name="picking_ids" position="attributes">
<attribute name="context">{'show_print_button': 1}</attribute>
<attribute name="domain">[('partner_id', '=', partner_id), ('picking_type_id.code', '=', picking_code), ('state', 'in', ('confirmed', 'partially_available', 'assigned'))]</attribute>
<attribute name="domain">[('company_id', '=', company_id), ('partner_id', '=', partner_id), ('picking_type_id.code', '=', picking_code), ('state', 'in', ('confirmed', 'partially_available', 'assigned'))]</attribute>
<!-- <attribute name="domain">[('partner_id', '=', partner_id), ('picking_type_id', '=', picking_type_id), ('state', 'in', ('confirmed', 'partially_available', 'assigned'))]</attribute> -->
</field>

Expand All @@ -96,7 +97,6 @@
<field name="qty_done" position="after">
<button name="split_lot" string="Lot Split" type="object" icon="fa-list" groups="stock.group_production_lot" attrs="{'invisible': ['|', ('lots_visible', '=', False), ('state', 'not in', ['confirmed', 'assigned', 'waiting', 'partially_available','done'])]}"/>
<button name="set_all_done" string="Set all Done" type="object" icon="fa-check" attrs="{'invisible': ['|', ('lots_visible', '=', True), ('state', 'not in', ['confirmed', 'assigned', 'waiting', 'partially_available'])]}"/>
<button name="show_details" string="Modify" type="object" icon="fa-pencil" groups="stock.group_locations" states="confirmed,assigned,waiting,partially_available"/>
</field>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion stock_batch_picking_ux/views/stock_move_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<attribute name="invisible">context.get('from_batch')</attribute>
</field>
<field name="qty_done" position="before">
<field name="ordered_qty" readonly="1"/>
<field name="product_uom_qty" readonly="1"/>
</field>
</field>
</record>
Expand Down
2 changes: 2 additions & 0 deletions stock_voucher/models/stock_picking_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit a86c2b6

Please sign in to comment.