Acción para crear una albarán con los productos seleccionados desde la lista y sus cantidades disponibles.
This commit is contained in:
parent
439064cb48
commit
303a1c515c
5 changed files with 94 additions and 0 deletions
2
product_create_stock_picking/__init__.py
Normal file
2
product_create_stock_picking/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
from . import models
|
||||
|
28
product_create_stock_picking/__manifest__.py
Normal file
28
product_create_stock_picking/__manifest__.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
'name': 'Product Create Stock Picking',
|
||||
'category': 'Warehouse',
|
||||
'summary': 'Add an action to create a stock picking from a selection of products.',
|
||||
'version': '12.0.0.0.1',
|
||||
'description': """
|
||||
|
||||
Add an action to create a stock picking from a selection of products.
|
||||
|
||||
""",
|
||||
'author': 'Criptomart',
|
||||
'depends': [
|
||||
'stock',
|
||||
],
|
||||
'external_dependencies': {'python': [], 'bin': []},
|
||||
'data': [
|
||||
'data/data.xml',
|
||||
],
|
||||
'qweb': [],
|
||||
'demo': [],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'application': True,
|
||||
"post_load": None,
|
||||
"pre_init_hook": None,
|
||||
"post_init_hook": None,
|
||||
"uninstall_hook": None,
|
||||
}
|
16
product_create_stock_picking/data/data.xml
Normal file
16
product_create_stock_picking/data/data.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<odoo>
|
||||
<data>
|
||||
|
||||
<record model="ir.actions.server" id="action_product_create_stock_picking">
|
||||
<field name="name">Transfiere éstos productos</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="product.model_product_template" />
|
||||
<field name="state">code</field>
|
||||
<field name="code">action =records.create_stock_picking()</field>
|
||||
<field name="binding_model_id" ref="product.model_product_template" />
|
||||
<field name="binding_type">action</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
2
product_create_stock_picking/models/__init__.py
Normal file
2
product_create_stock_picking/models/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
from . import product_template
|
||||
|
46
product_create_stock_picking/models/product_template.py
Normal file
46
product_create_stock_picking/models/product_template.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Copyright (C) 2021: Criptomart (https://criptomart.net)
|
||||
# @author Santi Noreña (<santi@criptomart.net>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
#import logging
|
||||
|
||||
from odoo import tools, models, fields, api, _
|
||||
|
||||
#_logger = logging.getLogger(__name__)
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
@api.multi
|
||||
def create_stock_picking(self):
|
||||
picking_vals = self.env['stock.picking'].default_get(self.env['stock.picking']._fields.keys())
|
||||
picking_vals.update({
|
||||
'picking_type_id' : self.env.ref('stock.picking_type_internal').id,
|
||||
'location_id': self.env.ref('stock.stock_location_stock').id,
|
||||
'location_dest_id': self.env.ref('stock.stock_location_stock').id,
|
||||
})
|
||||
picking = self.env['stock.picking'].create(picking_vals)
|
||||
|
||||
for p in self:
|
||||
_logger.warning("product : %s" %p.name)
|
||||
move_vals = {
|
||||
'name': p.name,
|
||||
'product_id': p.id,
|
||||
'product_uom_qty': p.qty_available,
|
||||
'product_uom': p.uom_id.id,
|
||||
'picking_id': picking.id,
|
||||
'location_id': self.env.ref('stock.stock_location_stock').id,
|
||||
'location_dest_id': self.env.ref('stock.stock_location_stock').id,
|
||||
'state': 'waiting',
|
||||
'procure_method': 'make_to_order',
|
||||
}
|
||||
picking.move_lines = [(0, 0, move_vals)]
|
||||
|
||||
views = [(self.env.ref('stock.view_picking_form').id, 'form')]
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'stock.picking',
|
||||
'res_id': picking.id,
|
||||
'target': 'current',
|
||||
'views': views,
|
||||
}
|
Loading…
Add table
Reference in a new issue