Skip to content

Commit

Permalink
[ADD]stock_batch_picking:solapa transferencias
Browse files Browse the repository at this point in the history
  • Loading branch information
jcadhoc committed Nov 21, 2023
1 parent 17c4024 commit 1cf758a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
15 changes: 12 additions & 3 deletions stock_batch_picking_ux/README.rst
Expand Up @@ -39,9 +39,18 @@ To configure this module, you need to:
Usage
=====

To use this module, you need to:

#. Go to ...
While creating a batch picking:
- Add the partner in the batch transfer, and then filter the transfers able to be selected according to it.
- Add the number of packages in the batch transfer
- For receipts, it add the supplier's shipping number.
- When pickings are selected while creating a new batch, we allow them to be unreserved and check availability.

While proccesing the batch picking:
- Add the possibility of processing stock.move.line from a list view.
- In the transfer lines it add information of the vouchers, from & to and source document, among others.
- Allow to unreserve everything from the batch.
- A smart button is added to go to the list view of associated transfers.
- When you click on a transfer (from the transfer tab) you see all the possible actions that would be seen by entering it directly, such as the possibility of printing the remittance.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
Expand Down
25 changes: 25 additions & 0 deletions stock_batch_picking_ux/models/stock_batch_picking.py
Expand Up @@ -43,6 +43,21 @@ class StockPickingBatch(models.Model):
related='picking_ids.vouchers',
)

picking_count = fields.Integer(
string="# Transferencias", compute="_compute_picking_count",
)

def _compute_picking_count(self):
"""Calculate number of pickings."""
groups = self.env["stock.picking"].read_group(
domain=[("batch_id", "in", self.ids)],
fields=["batch_id"],
groupby=["batch_id"],
)
counts = {g["batch_id"][0]: g["batch_id_count"] for g in groups}
for batch in self:
batch.picking_count = counts.get(batch.id, 0)

@api.depends('picking_ids')
def _compute_picking_type_data(self):
for rec in self:
Expand Down Expand Up @@ -145,3 +160,13 @@ def do_unreserve_picking(self):
pickings_todo = self.mapped('picking_ids')
self.write({'state': 'draft'})
pickings_todo.do_unreserve()

def action_view_stock_picking(self):
"""This function returns an action that display existing pickings of
given batch picking.
"""
self.ensure_one()
pickings = self.mapped("picking_ids")
action = self.env.ref("stock.action_picking_tree_all").read([])[0]
action["domain"] = [("id", "in", pickings.ids)]
return action
17 changes: 10 additions & 7 deletions stock_batch_picking_ux/views/stock_batch_picking_views.xml
Expand Up @@ -38,19 +38,22 @@
<field name="arch" type="xml">

<button name="action_assign" position="after">
<button name="do_unreserve_picking" string="Unreserve all"
type="object"
attrs="{'invisible': [('state', 'not in', ['assigned', 'in_progress'])]}"/>
<button name="do_unreserve_picking" string="Unreserve all" type="object" attrs="{'invisible': [('state', 'not in', ['assigned', 'in_progress'])]}"/>
</button>

<button name="action_cancel" position="attributes">
<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_highlight oe_inline oe_right" type="object" string="Procesar cantidades" attrs="{'invisible': [('state', 'in', ['draft', 'cancel', 'done'])]}"/>
</field>
<div name="button_box" position="after">
<button name="add_picking_operation" class="oe_highlight oe_inline oe_right" type="object" string="Procesar cantidades" attrs="{'invisible': [('state', 'in', ['draft', 'cancel', 'done'])]}"/>
<div class="oe_button_box" name="button_box">
<button name="action_view_stock_picking" class="oe_stat_button" icon="fa-truck" type="object">
<field string="Pickings" name="picking_count" widget="statinfo" />
</button>
</div>
</div>

<field name="user_id" position="before">
<field name="voucher_required" invisible="1"/>
Expand All @@ -61,7 +64,7 @@
<!-- <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_type_code','!=','incoming')], 'required': [('voucher_required','=',True)]}"/>
<field name="number_of_packages"/>
<!-- <field name="voucher_ids" attrs="{'invisible': [('picking_type_code','!=','incoming')]}" widget="many2many_tags" context="{'default_batch_picking': id}" domain="[('id', '=', False)]" options="{'create':True, 'create_edit':True}}"/> -->
<!-- <field name="voucher_ids" attrs="{'invisible': [('picking_type_code','!=','incoming')]}" widget="many2many_tags" context="{'default_batch_picking': id}" domain="[('id', '=', False)]" options="{'create':True, 'create_edit':True}}"/> -->
</field>

<field name="picking_ids" position="attributes">
Expand Down

0 comments on commit 1cf758a

Please sign in to comment.