mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of stock_picklist for 11.0
This commit is contained in:
16
stock_picklist/README.rst
Normal file
16
stock_picklist/README.rst
Normal file
@@ -0,0 +1,16 @@
|
||||
**********************
|
||||
Hibou - Stock Picklist
|
||||
**********************
|
||||
|
||||
Adds a `Picklist` button to picking batches (waves) that provides a summary grouped by location
|
||||
and product for all of the pickings in the batch.
|
||||
|
||||
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||
|
||||
|
||||
=======
|
||||
License
|
||||
=======
|
||||
|
||||
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
|
||||
Copyright Hibou Corp. 2018
|
||||
2
stock_picklist/__init__.py
Normal file
2
stock_picklist/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import report
|
||||
from . import models
|
||||
24
stock_picklist/__manifest__.py
Normal file
24
stock_picklist/__manifest__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
'name': 'Stock Picklist',
|
||||
'version': '11.0.1.0.0',
|
||||
'category': 'Tools',
|
||||
'depends': [
|
||||
'stock_picking_batch',
|
||||
],
|
||||
'description': """
|
||||
Stock Picklist
|
||||
==============
|
||||
|
||||
Adds a `Picklist` button to picking batches (waves) that provides a summary grouped by location
|
||||
and product for all of the pickings in the batch.
|
||||
""",
|
||||
'author': 'Hibou Corp.',
|
||||
'license': 'AGPL-3',
|
||||
'website': 'https://hibou.io/',
|
||||
'data': [
|
||||
'report/stock_picklist.xml',
|
||||
'views/stock_views.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
1
stock_picklist/models/__init__.py
Normal file
1
stock_picklist/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import stock_picking_batch
|
||||
13
stock_picklist/models/stock_picking_batch.py
Normal file
13
stock_picklist/models/stock_picking_batch.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class StockPickingBatch(models.Model):
|
||||
_inherit = 'stock.picking.batch'
|
||||
|
||||
@api.multi
|
||||
def print_pick_list(self):
|
||||
pickings = self.mapped('picking_ids')
|
||||
if not pickings:
|
||||
raise UserError(_('Nothing to print.'))
|
||||
return self.env.ref('stock_picklist.picklist').report_action(pickings, data=None, config=False)
|
||||
1
stock_picklist/report/__init__.py
Normal file
1
stock_picklist/report/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import stock_picklist
|
||||
36
stock_picklist/report/stock_picklist.py
Normal file
36
stock_picklist/report/stock_picklist.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from odoo import api, models
|
||||
from collections import namedtuple
|
||||
|
||||
LocationGroup = namedtuple('LocationGroup', ('location_id', 'lines'))
|
||||
ProductGroup = namedtuple('ProductGroup', ('product_id', 'qty'))
|
||||
|
||||
|
||||
class StockPicklist(models.AbstractModel):
|
||||
_name = 'report.stock_picklist.report_picklist'
|
||||
_template = 'stock_picklist.report_picklist'
|
||||
|
||||
@api.model
|
||||
def get_report_values(self, docids, data=None):
|
||||
report_name = 'stock_picklist.report_picklist'
|
||||
report = self.env['ir.actions.report']._get_report_from_name(report_name)
|
||||
stock_pickings = self.env['stock.picking'].browse(docids)
|
||||
stock_pack_operations = stock_pickings.mapped(lambda o: o.move_lines).mapped(lambda l: l.move_line_ids)
|
||||
|
||||
locations = stock_pack_operations.mapped(lambda o: o.location_id)
|
||||
_l = []
|
||||
for location in locations:
|
||||
operations = stock_pack_operations.filtered(lambda o: o.location_id.id == location.id)
|
||||
products = operations.mapped(lambda o: o.product_id)
|
||||
_p = []
|
||||
for product in products:
|
||||
qty = sum(operations.filtered(lambda o: o.product_id.id == product.id).mapped(lambda o: o.product_qty))
|
||||
_p.append(ProductGroup(product_id=product, qty=int(qty)))
|
||||
_p = sorted(_p, key=lambda p: -p.qty)
|
||||
_l.append(LocationGroup(location_id=location, lines=_p))
|
||||
|
||||
_l = sorted(_l, key=lambda l: l.location_id.name)
|
||||
return {
|
||||
'doc_ids': docids,
|
||||
'doc_model': report.model,
|
||||
'docs': _l,
|
||||
}
|
||||
51
stock_picklist/report/stock_picklist.xml
Normal file
51
stock_picklist/report/stock_picklist.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<report
|
||||
id="picklist"
|
||||
model="stock.picking"
|
||||
string="Picklist"
|
||||
report_type="qweb-pdf"
|
||||
name="stock_picklist.report_picklist"
|
||||
/>
|
||||
|
||||
<template id="report_picklist">
|
||||
<t t-call="web.basic_layout">
|
||||
<div class="page">
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<th/>
|
||||
<th>Qty</th>
|
||||
<th>Product</th>
|
||||
<th>Barcode</th>
|
||||
<th>Location</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="docs" t-as="l">
|
||||
<t t-foreach="l.lines" t-as="p">
|
||||
<tr>
|
||||
<td><img t-att-src="p.product_id.image_small and ('data:image/png;base64,' + to_text(p.product_id.image_small)) or '/web/static/src/img/placeholder.png'" width="50" height="50"/></td>
|
||||
<td><span t-esc="p.qty"/></td>
|
||||
<td>
|
||||
<span t-if="p.product_id.seller_ids" t-field="p.product_id.seller_ids[0].name" /> -
|
||||
<span t-field="p.product_id.default_code" /> :
|
||||
<span t-if="p.product_id.seller_ids" t-field="p.product_id.seller_ids[0].product_code" />
|
||||
<br />
|
||||
<span t-field="p.product_id.name"/>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<img t-if="p.product_id.barcode" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', p.product_id.barcode, 400, 80)" style="width:200px;height:40px"/>
|
||||
<br />
|
||||
<span t-if="p.product_id.barcode" t-field="p.product_id.barcode" />
|
||||
</td>
|
||||
<td><span t-esc="l.location_id.name"/></td>
|
||||
</tr>
|
||||
</t>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
13
stock_picklist/views/stock_views.xml
Normal file
13
stock_picklist/views/stock_views.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="stock_picking_batch_form_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.batch.form.form</field>
|
||||
<field name="model">stock.picking.batch</field>
|
||||
<field name="inherit_id" ref="stock_picking_batch.stock_picking_batch_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='print_picking']" position="after">
|
||||
<button name="print_pick_list" string="Picklist" type="object" class="oe_highlight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user