mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_request_kanban: Migration to 13.0
This commit is contained in:
committed by
Bernat Puig Font
parent
918801ec94
commit
6c8a1894b1
@@ -2,30 +2,27 @@
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
{
|
||||
'name': 'Stock Request kanban',
|
||||
'version': '12.0.1.0.1',
|
||||
'category': 'Reporting',
|
||||
'website': 'https://github.com/OCA/stock-logistics-warehouse',
|
||||
'author': 'Creu Blanca, Eficent, Odoo Community Association (OCA)',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Adds a stock request order, and takes stock requests as lines',
|
||||
'depends': [
|
||||
'stock_request',
|
||||
'barcodes',
|
||||
"name": "Stock Request kanban",
|
||||
"version": "13.0.1.0.1",
|
||||
"category": "Warehouse Management",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"author": "Creu Blanca, ForgeFlow, Odoo Community Association (OCA)",
|
||||
"license": "LGPL-3",
|
||||
"summary": "Adds a stock request order, and takes stock requests as lines",
|
||||
"depends": ["stock_request", "barcodes"],
|
||||
"data": [
|
||||
"data/stock_request_sequence_data.xml",
|
||||
"report/report_paper_format.xml",
|
||||
"wizard/wizard_stock_inventory_kanban_views.xml",
|
||||
"wizard/wizard_stock_request_kanban_views.xml",
|
||||
"wizard/wizard_stock_request_order_kanban_views.xml",
|
||||
"views/stock_request_order_views.xml",
|
||||
"views/stock_request_kanban_views.xml",
|
||||
"views/stock_inventory_kanban_views.xml",
|
||||
"views/stock_request_menu.xml",
|
||||
"report/stock_request_kanban_templates.xml",
|
||||
"security/ir.model.access.csv",
|
||||
],
|
||||
'data': [
|
||||
'data/stock_request_sequence_data.xml',
|
||||
'report/report_paper_format.xml',
|
||||
'wizard/wizard_stock_inventory_kanban_views.xml',
|
||||
'wizard/wizard_stock_request_kanban_views.xml',
|
||||
'wizard/wizard_stock_request_order_kanban_views.xml',
|
||||
'views/stock_request_order_views.xml',
|
||||
'views/stock_request_kanban_views.xml',
|
||||
'views/stock_inventory_kanban_views.xml',
|
||||
'views/stock_request_menu.xml',
|
||||
'report/stock_request_kanban_templates.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
"installable": True,
|
||||
"application": False,
|
||||
}
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="seq_stock_request_kanban" model="ir.sequence">
|
||||
<field name="name">Stock Request Kanban</field>
|
||||
<field name="code">stock.request.kanban</field>
|
||||
<field name="prefix">KB</field>
|
||||
<field name="padding">5</field>
|
||||
<field name="company_id" eval="False"/>
|
||||
<field name="company_id" eval="False" />
|
||||
</record>
|
||||
|
||||
<record id="seq_stock_inventory_kanban" model="ir.sequence">
|
||||
<field name="name">Stock Inventory Kanban</field>
|
||||
<field name="code">stock.inventory.kanban</field>
|
||||
<field name="prefix">IKB</field>
|
||||
<field name="padding">5</field>
|
||||
<field name="company_id" eval="False"/>
|
||||
<field name="company_id" eval="False" />
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -1,69 +1,76 @@
|
||||
# Copyright 2018 Creu Blanca
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo import api, fields, models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class StockInventoryKanban(models.Model):
|
||||
_name = 'stock.inventory.kanban'
|
||||
_description = 'Inventory for Kanban'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_name = "stock.inventory.kanban"
|
||||
_description = "Inventory for Kanban"
|
||||
_inherit = ["mail.thread", "mail.activity.mixin"]
|
||||
|
||||
name = fields.Char(
|
||||
readonly=True, states={'draft': [('readonly', False)]}, copy=False,
|
||||
readonly=True, states={"draft": [("readonly", False)]}, copy=False
|
||||
)
|
||||
state = fields.Selection(
|
||||
[
|
||||
('draft', 'Draft'),
|
||||
('in_progress', 'In progress'),
|
||||
('finished', 'Finished'),
|
||||
('closed', 'Closed'),
|
||||
('cancelled', 'Cancelled')
|
||||
("draft", "Draft"),
|
||||
("in_progress", "In progress"),
|
||||
("finished", "Finished"),
|
||||
("closed", "Closed"),
|
||||
("cancelled", "Cancelled"),
|
||||
],
|
||||
required=True, default='draft', readonly=True, copy=False,
|
||||
track_visibility='onchange'
|
||||
required=True,
|
||||
default="draft",
|
||||
readonly=True,
|
||||
copy=False,
|
||||
track_visibility="onchange",
|
||||
)
|
||||
warehouse_ids = fields.Many2many(
|
||||
'stock.warehouse', string='Warehouse',
|
||||
"stock.warehouse",
|
||||
string="Warehouse",
|
||||
ondelete="cascade",
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
)
|
||||
location_ids = fields.Many2many(
|
||||
'stock.location', string='Location',
|
||||
domain=[('usage', 'in', ['internal', 'transit'])],
|
||||
"stock.location",
|
||||
string="Location",
|
||||
domain=[("usage", "in", ["internal", "transit"])],
|
||||
ondelete="cascade",
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
)
|
||||
product_ids = fields.Many2many(
|
||||
'product.product', string='Products',
|
||||
domain=[('type', 'in', ['product', 'consu'])],
|
||||
ondelete='cascade',
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
"product.product",
|
||||
string="Products",
|
||||
domain=[("type", "in", ["product", "consu"])],
|
||||
ondelete="cascade",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
)
|
||||
kanban_ids = fields.Many2many(
|
||||
'stock.request.kanban',
|
||||
relation='stock_inventory_kanban_kanban',
|
||||
readonly=True, copy=False,
|
||||
"stock.request.kanban",
|
||||
relation="stock_inventory_kanban_kanban",
|
||||
readonly=True,
|
||||
copy=False,
|
||||
)
|
||||
scanned_kanban_ids = fields.Many2many(
|
||||
'stock.request.kanban',
|
||||
relation='stock_inventory_kanban_scanned_kanban',
|
||||
readonly=True, copy=False,
|
||||
"stock.request.kanban",
|
||||
relation="stock_inventory_kanban_scanned_kanban",
|
||||
readonly=True,
|
||||
copy=False,
|
||||
)
|
||||
missing_kanban_ids = fields.Many2many(
|
||||
'stock.request.kanban',
|
||||
readonly=True,
|
||||
compute='_compute_missing_kanban'
|
||||
"stock.request.kanban", readonly=True, compute="_compute_missing_kanban"
|
||||
)
|
||||
|
||||
count_missing_kanbans = fields.Integer(
|
||||
'Missing Kanbans',
|
||||
readonly=True,
|
||||
compute='_compute_missing_kanban',
|
||||
"Missing Kanbans", readonly=True, compute="_compute_missing_kanban"
|
||||
)
|
||||
|
||||
@api.depends('kanban_ids', 'scanned_kanban_ids')
|
||||
@api.depends("kanban_ids", "scanned_kanban_ids")
|
||||
def _compute_missing_kanban(self):
|
||||
for rec in self:
|
||||
rec.missing_kanban_ids = rec.kanban_ids.filtered(
|
||||
@@ -74,88 +81,73 @@ class StockInventoryKanban(models.Model):
|
||||
def _get_inventory_kanban_domain(self):
|
||||
domain = []
|
||||
if self.warehouse_ids:
|
||||
domain = expression.AND((
|
||||
domain, [('warehouse_id', 'in', self.warehouse_ids.ids)]
|
||||
))
|
||||
domain = expression.AND(
|
||||
(domain, [("warehouse_id", "in", self.warehouse_ids.ids)])
|
||||
)
|
||||
if self.product_ids:
|
||||
domain = expression.AND((
|
||||
domain, [('product_id', 'in', self.product_ids.ids)]
|
||||
))
|
||||
domain = expression.AND(
|
||||
(domain, [("product_id", "in", self.product_ids.ids)])
|
||||
)
|
||||
if self.location_ids:
|
||||
domain = expression.AND((
|
||||
domain, [('location_id', 'in', self.location_ids.ids)]
|
||||
))
|
||||
domain = expression.AND(
|
||||
(domain, [("location_id", "in", self.location_ids.ids)])
|
||||
)
|
||||
return domain
|
||||
|
||||
def _start_inventory_values(self):
|
||||
return {
|
||||
'state': 'in_progress'
|
||||
}
|
||||
return {"state": "in_progress"}
|
||||
|
||||
def _finish_inventory_values(self):
|
||||
return {
|
||||
'state': 'finished'
|
||||
}
|
||||
return {"state": "finished"}
|
||||
|
||||
def _close_inventory_values(self):
|
||||
return {
|
||||
'state': 'closed'
|
||||
}
|
||||
return {"state": "closed"}
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', '/') == '/':
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||
'stock.inventory.kanban')
|
||||
if vals.get("name", "/") == "/":
|
||||
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||
"stock.inventory.kanban"
|
||||
)
|
||||
return super().create(vals)
|
||||
|
||||
@api.multi
|
||||
def calculate_kanbans(self):
|
||||
for rec in self:
|
||||
if rec.state == 'draft':
|
||||
rec.kanban_ids = self.env['stock.request.kanban'].search(
|
||||
if rec.state == "draft":
|
||||
rec.kanban_ids = self.env["stock.request.kanban"].search(
|
||||
rec._get_inventory_kanban_domain()
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def start_inventory(self):
|
||||
self.calculate_kanbans()
|
||||
self.write(self._start_inventory_values())
|
||||
|
||||
@api.multi
|
||||
def finish_inventory(self):
|
||||
self.write(self._finish_inventory_values())
|
||||
|
||||
@api.multi
|
||||
def close_inventory(self):
|
||||
self.write(self._close_inventory_values())
|
||||
|
||||
@api.multi
|
||||
def print_missing_kanbans(self):
|
||||
""" Print the missing kanban cards in order to restore them
|
||||
"""
|
||||
self.ensure_one()
|
||||
return self.env.ref(
|
||||
'stock_request_kanban.action_report_kanban').report_action(
|
||||
return self.env.ref("stock_request_kanban.action_report_kanban").report_action(
|
||||
self.missing_kanban_ids
|
||||
)
|
||||
|
||||
def _cancel_inventory_values(self):
|
||||
return {
|
||||
'state': 'cancelled',
|
||||
}
|
||||
return {"state": "cancelled"}
|
||||
|
||||
@api.multi
|
||||
def cancel(self):
|
||||
self.write(self._cancel_inventory_values())
|
||||
|
||||
def _to_draft_inventory_values(self):
|
||||
return {
|
||||
'state': 'draft',
|
||||
'kanban_ids': [(5, 0)],
|
||||
'scanned_kanban_ids': [(5, 0)],
|
||||
"state": "draft",
|
||||
"kanban_ids": [(5, 0)],
|
||||
"scanned_kanban_ids": [(5, 0)],
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def to_draft(self):
|
||||
self.write(self._to_draft_inventory_values())
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Copyright 2018 Creu Blanca
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import models, fields
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class StockRequest(models.Model):
|
||||
_inherit = 'stock.request'
|
||||
_inherit = "stock.request"
|
||||
|
||||
kanban_id = fields.Many2one('stock.request.kanban', readonly=True)
|
||||
kanban_id = fields.Many2one("stock.request.kanban", readonly=True)
|
||||
|
||||
@@ -1,47 +1,52 @@
|
||||
# Copyright 2018 Creu Blanca
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from reportlab.graphics.barcode import getCodes
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class StockRequestKanban(models.Model):
|
||||
_name = 'stock.request.kanban'
|
||||
_description = 'Stock Request Kanban'
|
||||
_inherit = 'stock.request.abstract'
|
||||
_name = "stock.request.kanban"
|
||||
_description = "Stock Request Kanban"
|
||||
_inherit = "stock.request.abstract"
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', '/') == '/':
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||
'stock.request.kanban')
|
||||
if vals.get("name", "/") == "/":
|
||||
vals["name"] = self.env["ir.sequence"].next_by_code("stock.request.kanban")
|
||||
return super().create(vals)
|
||||
|
||||
@api.model
|
||||
def get_barcode_format(self):
|
||||
return self.env['ir.config_parameter'].sudo().get_param(
|
||||
'stock_request_kanban.barcode_format', default='Standard39'
|
||||
return (
|
||||
self.env["ir.config_parameter"]
|
||||
.sudo()
|
||||
.get_param("stock_request_kanban.barcode_format", default="Standard39")
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _recompute_barcode(self, barcode):
|
||||
if self.env['ir.config_parameter'].sudo().get_param(
|
||||
'stock_request_kanban.crc', default='1'
|
||||
) == '0':
|
||||
if (
|
||||
self.env["ir.config_parameter"]
|
||||
.sudo()
|
||||
.get_param("stock_request_kanban.crc", default="1")
|
||||
== "0"
|
||||
):
|
||||
return barcode
|
||||
bcc = getCodes()[self.get_barcode_format()](value=barcode[:-1])
|
||||
bcc.validate()
|
||||
bcc.encode()
|
||||
if bcc.encoded[1:-1] != barcode:
|
||||
raise ValidationError(_('CRC is not valid'))
|
||||
raise ValidationError(_("CRC is not valid"))
|
||||
return barcode[:-1]
|
||||
|
||||
@api.model
|
||||
def search_barcode(self, barcode):
|
||||
recomputed_barcode = self._recompute_barcode(barcode)
|
||||
return self.env['stock.request.kanban'].search([
|
||||
('name', '=', recomputed_barcode)
|
||||
])
|
||||
return self.env["stock.request.kanban"].search(
|
||||
[("name", "ilike", recomputed_barcode)]
|
||||
)
|
||||
|
||||
@@ -11,5 +11,4 @@
|
||||
<field name="header_spacing">0</field>
|
||||
<field name="dpi">72</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,83 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 Eficent
|
||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2017-2020 ForgeFlow, S.L.
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -->
|
||||
<odoo>
|
||||
<template id="report_simple_label">
|
||||
<div class="col-xs-3" style="padding:20;height:350px;">
|
||||
<div class="col-3" style="padding:20;height:350px;">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12"
|
||||
style="height:15%;border:2px solid black;text-align:center;vertical-align:middle;display:table;">
|
||||
<div
|
||||
class="col-12"
|
||||
style="height:15%;border:2px solid black;text-align:center;vertical-align:middle;display:table;"
|
||||
>
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<strong t-field="o.location_id.name"/>
|
||||
<strong t-field="o.location_id.name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row"
|
||||
t-if="o.product_id.default_code">
|
||||
<div class="col-xs-12"
|
||||
style="height:15%;border:2px solid black;text-align:center;vertical-align:middle;display:table;">
|
||||
<div class="row" t-if="o.product_id.default_code">
|
||||
<div
|
||||
class="col-12"
|
||||
style="height:15%;border:2px solid black;text-align:center;vertical-align:middle;display:table;"
|
||||
>
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<strong t-field="o.product_id.default_code"
|
||||
t-if="o.product_id.default_code"/>
|
||||
<strong
|
||||
t-field="o.product_id.default_code"
|
||||
t-if="o.product_id.default_code"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 align-middle"
|
||||
style="height:40%;border:2px solid black;text-align:center;vertical-align:middle;display:table;">
|
||||
<div
|
||||
class="col-12 align-middle"
|
||||
style="height:40%;border:2px solid black;text-align:center;vertical-align:middle;display:table;"
|
||||
>
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<strong t-field="o.product_id.name"/>
|
||||
<strong t-field="o.product_id.name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6"
|
||||
style="height:10%;border:2px solid black;text-align:center;vertical-align:middle;display:table;">
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<span t-esc="float(o.product_qty)"/>
|
||||
<span t-field="o.product_id.uom_id.name"/>
|
||||
<div
|
||||
class="col-6"
|
||||
style="height:10%;border:2px solid black;text-align:center;vertical-align:middle;"
|
||||
>
|
||||
<div style="vertical-align: middle;">
|
||||
<span t-esc="float(o.product_qty)" />
|
||||
<span t-field="o.product_id.uom_id.name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6"
|
||||
style="height:10%;border:2px solid black;text-align:center;vertical-align:middle;display:table;">
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<span t-esc="float(o.product_uom_qty)"/>
|
||||
<span t-field="o.product_uom_id.name"/>
|
||||
<div
|
||||
class="col-6"
|
||||
style="height:10%;border:2px solid black;text-align:center;vertical-align:middle;"
|
||||
>
|
||||
<div style="vertical-align: middle;">
|
||||
<span t-esc="float(o.product_uom_qty)" />
|
||||
<span t-field="o.product_uom_id.name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12"
|
||||
style="height:10%;border:2px solid black;text-align:center;vertical-align:middle;display:table;">
|
||||
<div
|
||||
class="col-12"
|
||||
style="height:10%;border:2px solid black;text-align:center;vertical-align:middle;display:table;"
|
||||
>
|
||||
<div style="display: table-cell; vertical-align: middle;">
|
||||
<span t-field="o.name"/>
|
||||
<span t-field="o.name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12" style="height:10%;">
|
||||
<img t-att-src="'/report/barcode/%s/%s?width=%s&height=%s' % (o.get_barcode_format(), o.name, 320, 20)"
|
||||
style="height:80%; width: 100%;"/>
|
||||
<div class="col-12" style="height:10%;">
|
||||
<img
|
||||
t-att-src="'/report/barcode/%s/%s?width=%s&height=%s' % (o.get_barcode_format(), o.name, 320, 20)"
|
||||
style="height:80%; width: 100%;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="report_kanban_label">
|
||||
<t t-call="web.basic_layout">
|
||||
<t t-foreach="docs" t-as="o">
|
||||
|
||||
<div class="page">
|
||||
<t t-call="stock_request_kanban.report_simple_label">
|
||||
<t t-set="o" t-value="o"/>
|
||||
<t t-set="o" t-value="o" />
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<report
|
||||
id="action_report_kanban"
|
||||
string="Print kanban"
|
||||
@@ -86,5 +98,6 @@
|
||||
name="stock_request_kanban.report_kanban_label"
|
||||
file="stock_request_kanban.report_kanban_label"
|
||||
paperformat="stock_request_kanban.kanban_paper_format"
|
||||
menu="True"/>
|
||||
menu="True"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
odoo.define("stock_request_kanban.StockRequestKanbanController", function(require) {
|
||||
"use strict";
|
||||
|
||||
var core = require("web.core");
|
||||
var ListController = require("web.ListController");
|
||||
|
||||
var qweb = core.qweb;
|
||||
|
||||
var StockRequestKanbanController = ListController.extend({
|
||||
// -------------------------------------------------------------------------
|
||||
// Public
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
init: function(parent, model, renderer) {
|
||||
this.context = renderer.state.getContext();
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
renderButtons: function($node) {
|
||||
this._super.apply(this, arguments);
|
||||
var $buttonScan = $(qweb.render("StockRequestKanban.Buttons"));
|
||||
$buttonScan.on("click", this._onOpenWizard.bind(this));
|
||||
|
||||
$buttonScan.prependTo($node.find(".o_list_buttons"));
|
||||
},
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Handlers
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
_onOpenWizard: function() {
|
||||
var context = {
|
||||
active_model: this.modelName,
|
||||
};
|
||||
this.do_action({
|
||||
res_model: "wizard.stock.request.kanban",
|
||||
views: [[false, "form"]],
|
||||
target: "new",
|
||||
type: "ir.actions.act_window",
|
||||
context: context,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return StockRequestKanbanController;
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
odoo.define("stock_request_kanban.StockRequestKanbanListView", function(require) {
|
||||
"use strict";
|
||||
|
||||
var ListView = require("web.ListView");
|
||||
var StockRequestKanbanController = require("stock_request_kanban.StockRequestKanbanController");
|
||||
var viewRegistry = require("web.view_registry");
|
||||
|
||||
var StockRequestKanbanListView = ListView.extend({
|
||||
config: _.extend({}, ListView.prototype.config, {
|
||||
Controller: StockRequestKanbanController,
|
||||
}),
|
||||
});
|
||||
|
||||
viewRegistry.add("stock_request_kanban_list", StockRequestKanbanListView);
|
||||
|
||||
return StockRequestKanbanListView;
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<button t-name="StockRequestKanban.Buttons" class="btn-primary btn" type="button">
|
||||
Scan Kanban
|
||||
</button>
|
||||
</templates>
|
||||
@@ -1,16 +1,17 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from reportlab.graphics.barcode import getCodes
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestBaseKanban(TransactionCase):
|
||||
|
||||
def pass_code(self, wizard, code):
|
||||
bcc = getCodes()[
|
||||
self.env['stock.request.kanban'].get_barcode_format()](value=code)
|
||||
bcc = getCodes()[self.env["stock.request.kanban"].get_barcode_format()](
|
||||
value=code
|
||||
)
|
||||
bcc.validate()
|
||||
bcc.encode()
|
||||
wizard.on_barcode_scanned(bcc.encoded[1:-1])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from .base_test import TestBaseKanban
|
||||
@@ -8,68 +8,78 @@ from .base_test import TestBaseKanban
|
||||
class TestKanban(TestBaseKanban):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.main_company = self.env.ref('base.main_company')
|
||||
self.route = self.env['stock.location.route'].create({
|
||||
'name': 'Transfer',
|
||||
'product_categ_selectable': False,
|
||||
'product_selectable': True,
|
||||
'company_id': self.main_company.id,
|
||||
'sequence': 10,
|
||||
})
|
||||
self.product = self.env['product.product'].create({
|
||||
'name': 'Product',
|
||||
'route_ids': [(4, self.route.id)],
|
||||
'company_id': False,
|
||||
})
|
||||
self.product_2 = self.env['product.product'].create({
|
||||
'name': 'Product 2',
|
||||
'route_ids': [(4, self.route.id)],
|
||||
'company_id': False,
|
||||
})
|
||||
self.kanban_1 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
self.kanban_2 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
self.kanban_3 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product_2.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
self.main_company = self.env.ref("base.main_company")
|
||||
self.route = self.env["stock.location.route"].create(
|
||||
{
|
||||
"name": "Transfer",
|
||||
"product_categ_selectable": False,
|
||||
"product_selectable": True,
|
||||
"company_id": self.main_company.id,
|
||||
"sequence": 10,
|
||||
}
|
||||
)
|
||||
self.product = self.env["product.product"].create(
|
||||
{"name": "Product", "route_ids": [(4, self.route.id)], "company_id": False}
|
||||
)
|
||||
self.product_2 = self.env["product.product"].create(
|
||||
{
|
||||
"name": "Product 2",
|
||||
"route_ids": [(4, self.route.id)],
|
||||
"company_id": False,
|
||||
}
|
||||
)
|
||||
self.kanban_1 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
self.kanban_2 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
self.kanban_3 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product_2.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
|
||||
def test_inventory_warehouse(self):
|
||||
inventory = self.env['stock.inventory.kanban'].create({
|
||||
'warehouse_ids': [(4, self.kanban_1.warehouse_id.id)],
|
||||
})
|
||||
inventory = self.env["stock.inventory.kanban"].create(
|
||||
{"warehouse_ids": [(4, self.kanban_1.warehouse_id.id)]}
|
||||
)
|
||||
inventory.start_inventory()
|
||||
self.assertIn(self.kanban_1, inventory.kanban_ids)
|
||||
self.assertIn(self.kanban_1, inventory.missing_kanban_ids)
|
||||
|
||||
def test_inventory_location(self):
|
||||
inventory = self.env['stock.inventory.kanban'].create({
|
||||
'location_ids': [(4, self.kanban_1.location_id.id)],
|
||||
})
|
||||
inventory = self.env["stock.inventory.kanban"].create(
|
||||
{"location_ids": [(4, self.kanban_1.location_id.id)]}
|
||||
)
|
||||
inventory.start_inventory()
|
||||
self.assertIn(self.kanban_1, inventory.kanban_ids)
|
||||
self.assertIn(self.kanban_1, inventory.missing_kanban_ids)
|
||||
|
||||
def test_inventory_product(self):
|
||||
inventory = self.env['stock.inventory.kanban'].create({
|
||||
'product_ids': [(4, self.product.id)],
|
||||
})
|
||||
inventory = self.env["stock.inventory.kanban"].create(
|
||||
{"product_ids": [(4, self.product.id)]}
|
||||
)
|
||||
inventory.start_inventory()
|
||||
self.assertIn(self.kanban_1, inventory.kanban_ids)
|
||||
self.assertNotIn(self.kanban_3, inventory.kanban_ids)
|
||||
self.assertIn(self.kanban_1, inventory.missing_kanban_ids)
|
||||
self.assertEqual(inventory.state, 'in_progress')
|
||||
wizard = self.env['wizard.stock.inventory.kanban'].with_context(
|
||||
default_inventory_kanban_id=inventory.id
|
||||
).create({})
|
||||
self.assertEqual(inventory.state, "in_progress")
|
||||
wizard = (
|
||||
self.env["wizard.stock.inventory.kanban"]
|
||||
.with_context(default_inventory_kanban_id=inventory.id)
|
||||
.create({})
|
||||
)
|
||||
self.pass_code(wizard, self.kanban_3.name)
|
||||
self.assertEqual(wizard.status_state, 1)
|
||||
self.pass_code(wizard, self.kanban_1.name)
|
||||
@@ -81,22 +91,22 @@ class TestKanban(TestBaseKanban):
|
||||
self.assertNotIn(self.kanban_1, inventory.missing_kanban_ids)
|
||||
self.assertIn(self.kanban_1, inventory.scanned_kanban_ids)
|
||||
inventory.finish_inventory()
|
||||
self.assertEqual(inventory.state, 'finished')
|
||||
self.assertEqual(inventory.state, "finished")
|
||||
inventory.close_inventory()
|
||||
self.assertEqual(inventory.state, 'closed')
|
||||
self.assertEqual(inventory.state, "closed")
|
||||
|
||||
def test_cancel_inventory(self):
|
||||
inventory = self.env['stock.inventory.kanban'].create({
|
||||
'product_ids': [(4, self.product.id)],
|
||||
})
|
||||
inventory = self.env["stock.inventory.kanban"].create(
|
||||
{"product_ids": [(4, self.product.id)]}
|
||||
)
|
||||
inventory.start_inventory()
|
||||
self.assertIn(self.kanban_1, inventory.kanban_ids)
|
||||
self.assertNotIn(self.kanban_3, inventory.kanban_ids)
|
||||
self.assertIn(self.kanban_1, inventory.missing_kanban_ids)
|
||||
self.assertEqual(inventory.state, 'in_progress')
|
||||
self.assertEqual(inventory.state, "in_progress")
|
||||
inventory.cancel()
|
||||
self.assertEqual(inventory.state, 'cancelled')
|
||||
self.assertEqual(inventory.state, "cancelled")
|
||||
inventory.to_draft()
|
||||
self.assertEqual(inventory.state, 'draft')
|
||||
self.assertEqual(inventory.state, "draft")
|
||||
self.assertFalse(inventory.kanban_ids)
|
||||
self.assertFalse(inventory.scanned_kanban_ids)
|
||||
|
||||
@@ -1,71 +1,74 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .base_test import TestBaseKanban
|
||||
|
||||
|
||||
class TestKanban(TestBaseKanban):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.main_company = self.env.ref('base.main_company')
|
||||
self.warehouse = self.env.ref('stock.warehouse0')
|
||||
self.categ_unit = self.env.ref('uom.product_uom_categ_unit')
|
||||
self.main_company = self.env.ref("base.main_company")
|
||||
self.warehouse = self.env.ref("stock.warehouse0")
|
||||
self.categ_unit = self.env.ref("uom.product_uom_categ_unit")
|
||||
|
||||
# common data
|
||||
self.company_2 = self.env['res.company'].create({
|
||||
'name': 'Comp2',
|
||||
})
|
||||
self.wh2 = self.env['stock.warehouse'].search(
|
||||
[('company_id', '=', self.company_2.id)], limit=1)
|
||||
self.wh3 = self.env['stock.warehouse'].create({
|
||||
'name': 'Warehouse TEst',
|
||||
'code': 'WH-TEST',
|
||||
'company_id': self.main_company.id,
|
||||
})
|
||||
self.company_2 = self.env["res.company"].create({"name": "Comp2"})
|
||||
self.wh2 = self.env["stock.warehouse"].search(
|
||||
[("company_id", "=", self.company_2.id)], limit=1
|
||||
)
|
||||
self.wh3 = self.env["stock.warehouse"].create(
|
||||
{
|
||||
"name": "Warehouse TEst",
|
||||
"code": "WH-TEST",
|
||||
"company_id": self.main_company.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.ressuply_loc = self.env['stock.location'].create({
|
||||
'name': 'Ressuply',
|
||||
'location_id': self.warehouse.view_location_id.id,
|
||||
})
|
||||
self.route = self.env['stock.location.route'].create({
|
||||
'name': 'Transfer',
|
||||
'product_categ_selectable': False,
|
||||
'product_selectable': True,
|
||||
'company_id': self.main_company.id,
|
||||
'sequence': 10,
|
||||
})
|
||||
self.product = self.env['product.product'].create({
|
||||
'name': 'Product',
|
||||
'route_ids': [(4, self.route.id)],
|
||||
'company_id': False,
|
||||
})
|
||||
self.uom_dozen = self.env['uom.uom'].create({
|
||||
'name': 'Test-DozenA',
|
||||
'category_id': self.categ_unit.id,
|
||||
'factor_inv': 12,
|
||||
'uom_type': 'bigger',
|
||||
'rounding': 0.001})
|
||||
self.ressuply_loc = self.env["stock.location"].create(
|
||||
{"name": "Ressuply", "location_id": self.warehouse.view_location_id.id}
|
||||
)
|
||||
self.route = self.env["stock.location.route"].create(
|
||||
{
|
||||
"name": "Transfer",
|
||||
"product_categ_selectable": False,
|
||||
"product_selectable": True,
|
||||
"company_id": self.main_company.id,
|
||||
"sequence": 10,
|
||||
}
|
||||
)
|
||||
self.product = self.env["product.product"].create(
|
||||
{"name": "Product", "route_ids": [(4, self.route.id)], "company_id": False}
|
||||
)
|
||||
self.uom_dozen = self.env["uom.uom"].create(
|
||||
{
|
||||
"name": "Test-DozenA",
|
||||
"category_id": self.categ_unit.id,
|
||||
"factor_inv": 12,
|
||||
"uom_type": "bigger",
|
||||
"rounding": 0.001,
|
||||
}
|
||||
)
|
||||
|
||||
self.env['stock.rule'].create({
|
||||
'name': 'Transfer',
|
||||
'route_id': self.route.id,
|
||||
'location_src_id': self.ressuply_loc.id,
|
||||
'location_id': self.warehouse.lot_stock_id.id,
|
||||
'action': 'pull_push',
|
||||
'picking_type_id': self.warehouse.int_type_id.id,
|
||||
'procure_method': 'make_to_stock',
|
||||
'warehouse_id': self.warehouse.id,
|
||||
'company_id': self.main_company.id,
|
||||
'propagate': 'False',
|
||||
})
|
||||
self.env['ir.config_parameter'].set_param(
|
||||
'stock_request_kanban.crc', '1')
|
||||
self.env["stock.rule"].create(
|
||||
{
|
||||
"name": "Transfer",
|
||||
"route_id": self.route.id,
|
||||
"location_src_id": self.ressuply_loc.id,
|
||||
"location_id": self.warehouse.lot_stock_id.id,
|
||||
"action": "pull_push",
|
||||
"picking_type_id": self.warehouse.int_type_id.id,
|
||||
"procure_method": "make_to_stock",
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"company_id": self.main_company.id,
|
||||
}
|
||||
)
|
||||
self.env["ir.config_parameter"].set_param("stock_request_kanban.crc", "1")
|
||||
|
||||
def test_onchanges(self):
|
||||
kanban = self.env['stock.request.kanban'].new({})
|
||||
kanban = self.env["stock.request.kanban"].new({})
|
||||
kanban.product_id = self.product
|
||||
kanban.onchange_product_id()
|
||||
kanban.company_id = self.main_company
|
||||
@@ -80,7 +83,7 @@ class TestKanban(TestBaseKanban):
|
||||
self.assertEqual(kanban.warehouse_id, self.warehouse)
|
||||
|
||||
def test_create(self):
|
||||
kanban = self.env['stock.request.kanban'].new({})
|
||||
kanban = self.env["stock.request.kanban"].new({})
|
||||
kanban.product_id = self.product
|
||||
kanban.onchange_product_id()
|
||||
kanban.product_uom_qty = 1
|
||||
@@ -89,95 +92,109 @@ class TestKanban(TestBaseKanban):
|
||||
self.assertEqual(kanban.route_ids, self.route)
|
||||
|
||||
def test_order_barcodes(self):
|
||||
kanban_1 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
kanban_2 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
kanban_3 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
'company_id': self.main_company.id,
|
||||
'warehouse_id': self.wh3.id,
|
||||
'location_id': self.wh3.lot_stock_id.id,
|
||||
})
|
||||
order = self.env['stock.request.order'].create({
|
||||
'company_id': self.main_company.id,
|
||||
'warehouse_id': self.warehouse.id,
|
||||
'location_id': self.warehouse.lot_stock_id.id,
|
||||
})
|
||||
wizard = self.env['wizard.stock.request.order.kanban'].with_context(
|
||||
default_order_id=order.id
|
||||
).create({})
|
||||
kanban_1 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
kanban_2 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
kanban_3 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
"company_id": self.main_company.id,
|
||||
"warehouse_id": self.wh3.id,
|
||||
"location_id": self.wh3.lot_stock_id.id,
|
||||
}
|
||||
)
|
||||
order = self.env["stock.request.order"].create(
|
||||
{
|
||||
"company_id": self.main_company.id,
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"location_id": self.warehouse.lot_stock_id.id,
|
||||
}
|
||||
)
|
||||
wizard = (
|
||||
self.env["wizard.stock.request.order.kanban"]
|
||||
.with_context(default_order_id=order.id)
|
||||
.create({})
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
wizard.on_barcode_scanned(kanban_1.name)
|
||||
self.pass_code(wizard, kanban_1.name)
|
||||
self.assertEqual(wizard.status_state, 0)
|
||||
self.assertTrue(order.stock_request_ids.filtered(
|
||||
lambda r: r.kanban_id == kanban_1
|
||||
))
|
||||
self.assertTrue(
|
||||
order.stock_request_ids.filtered(lambda r: r.kanban_id == kanban_1)
|
||||
)
|
||||
self.pass_code(wizard, kanban_2.name)
|
||||
self.assertTrue(order.stock_request_ids.filtered(
|
||||
lambda r: r.kanban_id == kanban_2
|
||||
))
|
||||
self.assertTrue(
|
||||
order.stock_request_ids.filtered(lambda r: r.kanban_id == kanban_2)
|
||||
)
|
||||
self.assertEqual(wizard.status_state, 0)
|
||||
self.pass_code(wizard, kanban_1.name)
|
||||
self.assertEqual(wizard.status_state, 1)
|
||||
self.pass_code(wizard, kanban_2.name+kanban_1.name)
|
||||
self.pass_code(wizard, kanban_2.name + kanban_1.name)
|
||||
self.assertEqual(wizard.status_state, 1)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.pass_code(wizard, kanban_3.name)
|
||||
|
||||
def test_barcodes(self):
|
||||
kanban_1 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
kanban_2 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
kanban_3 = self.env['stock.request.kanban'].create({
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
wizard = self.env['wizard.stock.request.kanban'].with_context(
|
||||
).create({})
|
||||
kanban_1 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
kanban_2 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
kanban_3 = self.env["stock.request.kanban"].create(
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 1,
|
||||
}
|
||||
)
|
||||
wizard = self.env["wizard.stock.request.kanban"].with_context().create({})
|
||||
with self.assertRaises(ValidationError):
|
||||
wizard.on_barcode_scanned(kanban_1.name)
|
||||
self.assertFalse(self.env['stock.request'].search(
|
||||
[('kanban_id', '=', kanban_1.id)])
|
||||
self.assertFalse(
|
||||
self.env["stock.request"].search([("kanban_id", "=", kanban_1.id)])
|
||||
)
|
||||
self.pass_code(wizard, kanban_1.name)
|
||||
self.assertEqual(wizard.status_state, 0)
|
||||
self.assertTrue(self.env['stock.request'].search(
|
||||
[('kanban_id', '=', kanban_1.id)])
|
||||
self.assertTrue(
|
||||
self.env["stock.request"].search([("kanban_id", "=", kanban_1.id)])
|
||||
)
|
||||
self.assertFalse(self.env['stock.request'].search(
|
||||
[('kanban_id', '=', kanban_2.id)])
|
||||
self.assertFalse(
|
||||
self.env["stock.request"].search([("kanban_id", "=", kanban_2.id)])
|
||||
)
|
||||
self.pass_code(wizard, kanban_2.name)
|
||||
self.assertTrue(self.env['stock.request'].search(
|
||||
[('kanban_id', '=', kanban_2.id)])
|
||||
self.assertTrue(
|
||||
self.env["stock.request"].search([("kanban_id", "=", kanban_2.id)])
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
wizard.on_barcode_scanned(kanban_3.name)
|
||||
self.assertFalse(self.env['stock.request'].search(
|
||||
[('kanban_id', '=', kanban_3.id)])
|
||||
self.assertFalse(
|
||||
self.env["stock.request"].search([("kanban_id", "=", kanban_3.id)])
|
||||
)
|
||||
self.env['ir.config_parameter'].set_param(
|
||||
'stock_request_kanban.crc', '0')
|
||||
self.env["ir.config_parameter"].set_param("stock_request_kanban.crc", "0")
|
||||
wizard.on_barcode_scanned(kanban_3.name)
|
||||
self.assertEqual(wizard.status_state, 0)
|
||||
self.assertTrue(self.env['stock.request'].search(
|
||||
[('kanban_id', '=', kanban_3.id)])
|
||||
self.assertTrue(
|
||||
self.env["stock.request"].search([("kanban_id", "=", kanban_3.id)])
|
||||
)
|
||||
|
||||
57
stock_request_kanban/views/product_views.xml
Normal file
57
stock_request_kanban/views/product_views.xml
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2020 ForgeFlow, S.L.
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/gpl). -->
|
||||
<odoo>
|
||||
<record id="product_product_form_view_kanban_card_button" model="ir.ui.view">
|
||||
<field name="name">product.product.stock.request.kanban</field>
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="product.product_normal_form_view" />
|
||||
<field
|
||||
name="groups_id"
|
||||
eval="[(4, ref('stock_request.group_stock_request_user'))]"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
name="action_view_kanban_cards"
|
||||
type="object"
|
||||
attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}"
|
||||
icon="fa-barcode"
|
||||
>
|
||||
<field
|
||||
string="Kanban Cards"
|
||||
name="kanban_card_count"
|
||||
widget="statinfo"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
<record id="product_template_form_view_bom_button" model="ir.ui.view">
|
||||
<field name="name">product.template.stock.request.kanban</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_only_form_view" />
|
||||
<field
|
||||
name="groups_id"
|
||||
eval="[(4, ref('stock_request.group_stock_request_user'))]"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
name="action_view_kanban_cards"
|
||||
type="object"
|
||||
attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}"
|
||||
icon="fa-barcode"
|
||||
>
|
||||
<field
|
||||
string="Kanban Cards"
|
||||
name="kanban_card_count"
|
||||
widget="statinfo"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,47 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_stock_inventory_kanban_tree" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.kanban.tree</field>
|
||||
<field name="model">stock.inventory.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock Inventories">
|
||||
<field name="name"/>
|
||||
<field name="count_missing_kanbans"/>
|
||||
<field name="state"/>
|
||||
<field name="name" />
|
||||
<field name="count_missing_kanbans" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_inventory_kanban_form" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.kanban.form</field>
|
||||
<field name="model">stock.inventory.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Stock Inventories">
|
||||
<header>
|
||||
<button name="start_inventory" type="object" string="Start"
|
||||
states="draft" class="btn-primary"
|
||||
<button
|
||||
name="start_inventory"
|
||||
type="object"
|
||||
string="Start"
|
||||
states="draft"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button name="finish_inventory" type="object" string="Finish"
|
||||
states="in_progress" class="btn-primary"
|
||||
<button
|
||||
name="finish_inventory"
|
||||
type="object"
|
||||
string="Finish"
|
||||
states="in_progress"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button name="print_missing_kanbans" type="object" string="Print missing"
|
||||
<button
|
||||
name="print_missing_kanbans"
|
||||
type="object"
|
||||
string="Print missing"
|
||||
states="finished"
|
||||
/>
|
||||
<button name="close_inventory" type="object" string="Close"
|
||||
states="finished" class="btn-primary"
|
||||
<button
|
||||
name="close_inventory"
|
||||
type="object"
|
||||
string="Close"
|
||||
states="finished"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button name="cancel" type="object" string="Cancel"
|
||||
<button
|
||||
name="cancel"
|
||||
type="object"
|
||||
string="Cancel"
|
||||
states="draft,in_progress,finished"
|
||||
/>
|
||||
<button name="to_draft" type="object" string="Set to draft"
|
||||
<button
|
||||
name="to_draft"
|
||||
type="object"
|
||||
string="Set to draft"
|
||||
states="cancelled"
|
||||
/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
<field name="state" widget="statusbar" />
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="%(stock_request_kanban.wizard_stock_inventory_kanban_action)d"
|
||||
<button
|
||||
name="%(stock_request_kanban.wizard_stock_inventory_kanban_action)d"
|
||||
type="action"
|
||||
icon="fa-barcode"
|
||||
string="Scan"
|
||||
@@ -52,40 +72,46 @@
|
||||
<div class="oe_title">
|
||||
<label for="name" string="Inventory Kanban" />
|
||||
<h1>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="name" readonly="1" />
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<field name="warehouse_ids" widget="many2many_tags" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_ids" widget="many2many_tags" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_ids" widget="many2many_tags"/>
|
||||
<field
|
||||
name="warehouse_ids"
|
||||
widget="many2many_tags"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field
|
||||
name="location_ids"
|
||||
widget="many2many_tags"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field name="product_ids" widget="many2many_tags" />
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Kanban" id="kanban">
|
||||
<field name="kanban_ids"/>
|
||||
<field name="kanban_ids" />
|
||||
</page>
|
||||
<page string="Missing" id="missing">
|
||||
<field name="missing_kanban_ids"/>
|
||||
<field name="missing_kanban_ids" />
|
||||
</page>
|
||||
<page string="Scanned" id="scanned">
|
||||
<field name="scanned_kanban_ids"/>
|
||||
<field name="scanned_kanban_ids" />
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="activity_ids" widget="mail_activity"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
<field name="message_follower_ids" widget="mail_followers" />
|
||||
<field name="activity_ids" widget="mail_activity" />
|
||||
<field name="message_ids" widget="mail_thread" />
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_inventory_kanban_action" model="ir.actions.act_window">
|
||||
<field name="name">Stock Inventory Kanbans</field>
|
||||
<field name="res_model">stock.inventory.kanban</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
@@ -93,5 +119,4 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,139 +1,193 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 Eficent
|
||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2017-2020 ForgeFlow, S.L.
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -->
|
||||
<odoo>
|
||||
|
||||
<record id="view_stock_request_kanban_tree" model="ir.ui.view">
|
||||
<field name="name">stock.request.kanban.tree</field>
|
||||
<field name="model">stock.request.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock Requests" decoration-muted="active == 'false'" decoration-bf="message_needaction==True">
|
||||
<field name="message_needaction" invisible="1"/>
|
||||
<field name="name"/>
|
||||
<field name="warehouse_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="route_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_uom_id"
|
||||
options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
|
||||
<field name="product_uom_qty"/>
|
||||
<field name="active" invisible="1"/>
|
||||
<tree
|
||||
string="Stock Requests"
|
||||
decoration-muted="active == 'false'"
|
||||
decoration-bf="message_needaction==True"
|
||||
>
|
||||
<field name="message_needaction" invisible="1" />
|
||||
<field name="name" />
|
||||
<field name="warehouse_id" groups="stock.group_stock_multi_locations" />
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations" />
|
||||
<field
|
||||
name="route_id"
|
||||
options="{'no_create': True}"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field name="product_id" />
|
||||
<field
|
||||
name="product_uom_id"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field name="product_uom_qty" />
|
||||
<field name="active" invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="stock_request_kanban_search">
|
||||
<field name="name">stock.request.kanban.search</field>
|
||||
<field name="model">stock.request.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Stock Requests Kanban">
|
||||
<field name="name" string="Stock Requests Kanban"/>
|
||||
<field name="warehouse_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="product_id"/>
|
||||
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
|
||||
<field name="name" string="Stock Requests Kanban" />
|
||||
<field name="warehouse_id" groups="stock.group_stock_multi_locations" />
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="product_id" />
|
||||
<filter
|
||||
string="Archived"
|
||||
name="inactive"
|
||||
domain="[('active','=',False)]"
|
||||
/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="warehouse" string="Warehouse" domain="[]" context="{'group_by':'warehouse_id'}"/>
|
||||
<filter name="location" string="Location" domain="[]" context="{'group_by':'location_id'}"/>
|
||||
<filter
|
||||
name="warehouse"
|
||||
string="Warehouse"
|
||||
domain="[]"
|
||||
context="{'group_by':'warehouse_id'}"
|
||||
/>
|
||||
<filter
|
||||
name="location"
|
||||
string="Location"
|
||||
domain="[]"
|
||||
context="{'group_by':'location_id'}"
|
||||
/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_request_kanban_form" model="ir.ui.view">
|
||||
<field name="name">stock.request.kanban.form</field>
|
||||
<field name="model">stock.request.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Stock Requests">
|
||||
<header/>
|
||||
<header />
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box"/>
|
||||
<div class="oe_button_box" name="button_box" />
|
||||
<div class="oe_title">
|
||||
<label for="name" string="Stock Request Kanban" />
|
||||
<h1>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="name" readonly="1" />
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="product_id"/>
|
||||
<field name="product_id" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="warehouse_id" widget="selection" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="route_id"
|
||||
options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="route_ids" invisible="1"/>
|
||||
<field name="procurement_group_id"
|
||||
groups="stock.group_adv_location"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
<field
|
||||
name="warehouse_id"
|
||||
widget="selection"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field
|
||||
name="location_id"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field
|
||||
name="route_id"
|
||||
options="{'no_create': True}"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field name="route_ids" invisible="1" />
|
||||
<field
|
||||
name="procurement_group_id"
|
||||
groups="stock.group_adv_location"
|
||||
/>
|
||||
<field
|
||||
name="company_id"
|
||||
groups="base.group_multi_company"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</group>
|
||||
<group name="quantities">
|
||||
<label for="product_uom_qty"/>
|
||||
<label for="product_uom_qty" />
|
||||
<div>
|
||||
<field name="product_uom_qty"
|
||||
class="oe_inline"/>
|
||||
<field name="product_uom_id"
|
||||
<field name="product_uom_qty" class="oe_inline" />
|
||||
<field
|
||||
name="product_uom_id"
|
||||
class="oe_inline"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
groups="uom.group_uom"/>
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="activity_ids" widget="mail_activity"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
<field name="message_follower_ids" widget="mail_followers" />
|
||||
<field name="activity_ids" widget="mail_activity" />
|
||||
<field name="message_ids" widget="mail_thread" />
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Partner Kanban View -->
|
||||
<record model="ir.ui.view" id="stock_request_kanban_kanban_view">
|
||||
<field name="name">stock.request.kanban.kanban</field>
|
||||
<field name="model">stock.request.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="o_res_partner_kanban">
|
||||
<field name="id"/>
|
||||
<field name="name"/>
|
||||
<field name="product_id"/>
|
||||
<field name="display_name"/>
|
||||
<field name="warehouse_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="id" />
|
||||
<field name="name" />
|
||||
<field name="product_id" />
|
||||
<field name="display_name" />
|
||||
<field name="warehouse_id" />
|
||||
<field name="location_id" />
|
||||
<field name="product_qty" />
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_global_click o_res_partner_kanban">
|
||||
|
||||
<div class="o_kanban_image">
|
||||
<img t-att-src="kanban_image('product.product', 'image_small', record.product_id.raw_value)" alt="Kanban Image"/>
|
||||
<img
|
||||
t-att-src="kanban_image('product.product', 'image_small', record.product_id.raw_value)"
|
||||
alt="Kanban Image"
|
||||
/>
|
||||
</div>
|
||||
<div class="oe_kanban_details">
|
||||
<strong class="o_kanban_record_title"><field name="display_name"/></strong>
|
||||
<div class="o_kanban_tags_section"/>
|
||||
<strong class="o_kanban_record_title">
|
||||
<field name="display_name" />
|
||||
</strong>
|
||||
<div class="o_kanban_tags_section" />
|
||||
<ul>
|
||||
<li t-if="record.product_id.raw_value"><field name="product_id"/></li>
|
||||
<li t-if="record.warehouse_id.raw_value" groups="stock.group_stock_multi_locations"><field name="warehouse_id"/></li>
|
||||
<li t-if="record.location_id.raw_value" groups="stock.group_stock_multi_locations"><field name="location_id"/></li>
|
||||
<li t-if="record.product_qty"><field name="product_qty"/> <field name="product_uom_id"/></li>
|
||||
<li t-if="record.product_id.raw_value">
|
||||
<field name="product_id" />
|
||||
</li>
|
||||
<li
|
||||
t-if="record.warehouse_id.raw_value"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
>
|
||||
<field name="warehouse_id" />
|
||||
</li>
|
||||
<li
|
||||
t-if="record.location_id.raw_value"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
>
|
||||
<field name="location_id" />
|
||||
</li>
|
||||
<li t-if="record.product_qty">
|
||||
<field name="product_qty" />
|
||||
<field name="product_uom_id" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_request_kanban_action" model="ir.actions.act_window">
|
||||
<field name="name">Stock Request Kanbans</field>
|
||||
<field name="res_model">stock.request.kanban</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
@@ -141,5 +195,4 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<menuitem id="stock_request_kanban_menu"
|
||||
<menuitem
|
||||
id="stock_request_kanban_menu"
|
||||
name="Kanban cards"
|
||||
parent="stock_request.menu_stock_request_master_data"
|
||||
action="stock_request_kanban_action"
|
||||
groups="stock_request.group_stock_request_manager"
|
||||
sequence="110"/>
|
||||
|
||||
<menuitem id="menu_wizard_stock_request_kanban"
|
||||
sequence="110"
|
||||
/>
|
||||
<menuitem
|
||||
id="menu_wizard_stock_request_kanban"
|
||||
name="Request from Kanban cards"
|
||||
parent="stock_request.menu_stock_request_operations"
|
||||
action="wizard_stock_request_kanban_action"
|
||||
sequence="40"/>
|
||||
|
||||
<menuitem id="menu_wizard_stock_inventory_kanban"
|
||||
sequence="40"
|
||||
/>
|
||||
<menuitem
|
||||
id="menu_wizard_stock_inventory_kanban"
|
||||
name="Inventory"
|
||||
parent="stock_request.menu_stock_request_operations"
|
||||
action="stock_inventory_kanban_action"
|
||||
sequence="60"/>
|
||||
sequence="60"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="stock_request_order_form">
|
||||
<field name="name">stock.request.order.form</field>
|
||||
<field name="model">stock.request.order</field>
|
||||
<field name="inherit_id" ref="stock_request.stock_request_order_form"/>
|
||||
<field name="inherit_id" ref="stock_request.stock_request_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(stock_request_kanban.wizard_stock_request_order_kanban_action)d"
|
||||
<button
|
||||
name="%(stock_request_kanban.wizard_stock_request_order_kanban_action)d"
|
||||
type="action"
|
||||
icon="fa-barcode"
|
||||
string="Scan"
|
||||
@@ -17,5 +17,4 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
31
stock_request_kanban/views/stock_request_views.xml
Normal file
31
stock_request_kanban/views/stock_request_views.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2017 Eficent
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -->
|
||||
<odoo>
|
||||
<template
|
||||
id="stock_request_kanban_assets_backend"
|
||||
name="stock_request_kanban assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/stock_request_kanban/static/src/js/stock_request_kanban_scan_controller.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/stock_request_kanban/static/src/js/stock_request_kanban_scan_view.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
<record id="view_stock_request_tree" model="ir.ui.view">
|
||||
<field name="name">stock.request.tree</field>
|
||||
<field name="model">stock.request</field>
|
||||
<field name="inherit_id" ref="stock_request.view_stock_request_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<attribute name="js_class">stock_request_kanban_list</attribute>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,24 +1,20 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class WizardStockRequestOrderKanbanAbstract(models.TransientModel):
|
||||
class WizardStockInventoryKanban(models.TransientModel):
|
||||
_name = "wizard.stock.inventory.kanban"
|
||||
_description = "Stock Inventory Kanban Wizard"
|
||||
_inherit = "wizard.stock.request.kanban.abstract"
|
||||
|
||||
inventory_kanban_id = fields.Many2one(
|
||||
'stock.inventory.kanban',
|
||||
readonly=True,
|
||||
)
|
||||
inventory_kanban_id = fields.Many2one("stock.inventory.kanban", readonly=True)
|
||||
|
||||
def barcode_ending(self):
|
||||
super().barcode_ending()
|
||||
self.inventory_kanban_id.write({
|
||||
'scanned_kanban_ids': [(4, self.kanban_id.id)]
|
||||
})
|
||||
self.inventory_kanban_id.write({"scanned_kanban_ids": [(4, self.kanban_id.id)]})
|
||||
|
||||
def validate_kanban(self, barcode):
|
||||
res = super().validate_kanban(barcode)
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
Copyright 2017-2020 ForgeFlow, S.L.
|
||||
Copyright 2017 Creu Blanca
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="wizard_stock_inventory_kanban_form" model="ir.ui.view">
|
||||
<field name="name">wizard.stock.inventory.kanban.form</field>
|
||||
<field name="model">wizard.stock.inventory.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add Kanban">
|
||||
<div class="alert alert-success text-center o_form_header"
|
||||
role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '!=', 0)]}">
|
||||
<bold><field name="status"/></bold>
|
||||
<div
|
||||
class="alert alert-success text-center o_form_header"
|
||||
role="alert"
|
||||
style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '!=', 0)]}"
|
||||
>
|
||||
<bold>
|
||||
<field name="status" />
|
||||
</bold>
|
||||
</div>
|
||||
<div class="alert alert-danger alert-dismissable text-center"
|
||||
role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '=', 0)]}">
|
||||
<bold><field name="status"/></bold>
|
||||
<div
|
||||
class="alert alert-danger alert-dismissable text-center"
|
||||
role="alert"
|
||||
style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '=', 0)]}"
|
||||
>
|
||||
<bold>
|
||||
<field name="status" />
|
||||
</bold>
|
||||
</div>
|
||||
<field name="status_state" invisible="1"/>
|
||||
<field name="kanban_id" invisible="1"/>
|
||||
<field name="inventory_kanban_id" invisible="1"/>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"
|
||||
invisible="1"/>
|
||||
<field name="status_state" invisible="1" />
|
||||
<field name="kanban_id" invisible="1" />
|
||||
<field name="inventory_kanban_id" invisible="1" />
|
||||
<field name="_barcode_scanned" widget="barcode_handler" />
|
||||
<footer>
|
||||
<button
|
||||
name="action_cancel"
|
||||
@@ -39,13 +45,12 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="wizard_stock_inventory_kanban_action"
|
||||
<act_window
|
||||
id="wizard_stock_inventory_kanban_action"
|
||||
name="Add Kanban"
|
||||
res_model="wizard.stock.inventory.kanban"
|
||||
view_mode="form"
|
||||
view_type="form"
|
||||
context="{'default_inventory_kanban_id': active_id}"
|
||||
target="new"/>
|
||||
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -1,44 +1,51 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class WizardStockRequestOrderKanbanAbstract(models.TransientModel):
|
||||
class WizardStockRequestKanban(models.TransientModel):
|
||||
_name = "wizard.stock.request.kanban"
|
||||
_description = "Stock Request Kanban Wizard"
|
||||
_inherit = "wizard.stock.request.kanban.abstract"
|
||||
|
||||
stock_request_id = fields.Many2one(
|
||||
'stock.request',
|
||||
readonly=True,
|
||||
)
|
||||
stock_request_id = fields.Many2one("stock.request", readonly=True)
|
||||
|
||||
def barcode_ending(self):
|
||||
super().barcode_ending()
|
||||
self.stock_request_id = self.env['stock.request'].create(
|
||||
self.stock_request_id = self.env["stock.request"].create(
|
||||
self.stock_request_kanban_values()
|
||||
)
|
||||
self.status_state = 0
|
||||
self.status = _('Added kanban %s for product %s' % (
|
||||
self.stock_request_id.kanban_id.name,
|
||||
self.stock_request_id.product_id.display_name
|
||||
))
|
||||
self.stock_request_ending()
|
||||
self.update_status()
|
||||
|
||||
def stock_request_ending(self):
|
||||
self.stock_request_id.action_confirm()
|
||||
|
||||
def update_status(self):
|
||||
self.update(
|
||||
{
|
||||
"status_state": 0,
|
||||
"status": _(
|
||||
"Added kanban %s for product %s"
|
||||
% (
|
||||
self.stock_request_id.kanban_id.name,
|
||||
self.stock_request_id.product_id.display_name,
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
def stock_request_kanban_values(self):
|
||||
return {
|
||||
'company_id': self.kanban_id.company_id.id,
|
||||
'procurement_group_id':
|
||||
self.kanban_id.procurement_group_id.id or False,
|
||||
'location_id': self.kanban_id.location_id.id or False,
|
||||
'warehouse_id': self.kanban_id.warehouse_id.id or False,
|
||||
'product_id': self.kanban_id.product_id.id,
|
||||
'product_uom_id': self.kanban_id.product_uom_id.id or False,
|
||||
'route_id': self.kanban_id.route_id.id or False,
|
||||
'product_uom_qty': self.kanban_id.product_uom_qty,
|
||||
'kanban_id': self.kanban_id.id,
|
||||
"company_id": self.kanban_id.company_id.id,
|
||||
"procurement_group_id": self.kanban_id.procurement_group_id.id or False,
|
||||
"location_id": self.kanban_id.location_id.id or False,
|
||||
"warehouse_id": self.kanban_id.warehouse_id.id or False,
|
||||
"product_id": self.kanban_id.product_id.id,
|
||||
"product_uom_id": self.kanban_id.product_uom_id.id or False,
|
||||
"route_id": self.kanban_id.route_id.id or False,
|
||||
"product_uom_qty": self.kanban_id.product_uom_qty,
|
||||
"kanban_id": self.kanban_id.id,
|
||||
}
|
||||
|
||||
@@ -1,47 +1,44 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class WizardStockRequestOrderKanbanAbstract(models.AbstractModel):
|
||||
class WizardStockRequestKanbanAbstract(models.AbstractModel):
|
||||
_name = "wizard.stock.request.kanban.abstract"
|
||||
_description = "Stock Request Kanban Abstract Wizard"
|
||||
_inherit = "barcodes.barcode_events_mixin"
|
||||
|
||||
kanban_id = fields.Many2one(
|
||||
'stock.request.kanban',
|
||||
readonly=True,
|
||||
)
|
||||
status = fields.Text(
|
||||
readonly=True,
|
||||
default="Start scanning",
|
||||
)
|
||||
status_state = fields.Integer(
|
||||
default=0,
|
||||
readonly=True,
|
||||
)
|
||||
kanban_id = fields.Many2one("stock.request.kanban", readonly=True)
|
||||
status = fields.Text(readonly=True, default="Start scanning")
|
||||
status_state = fields.Integer(default=0, readonly=True)
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
self.kanban_id = self.env['stock.request.kanban'].search_barcode(
|
||||
barcode)
|
||||
self.kanban_id = self.env["stock.request.kanban"].search_barcode(barcode)
|
||||
if not self.kanban_id:
|
||||
self.status = _("Barcode %s does not correspond to any "
|
||||
self.status = (
|
||||
_(
|
||||
"Barcode %s does not correspond to any "
|
||||
"Kanban. Try with another barcode or "
|
||||
"press Close to finish scanning.") % barcode
|
||||
"press Close to finish scanning."
|
||||
)
|
||||
% barcode
|
||||
)
|
||||
self.status_state = 1
|
||||
return
|
||||
if self.validate_kanban(barcode):
|
||||
self.status_state = 0
|
||||
self.barcode_ending()
|
||||
return
|
||||
|
||||
def barcode_ending(self):
|
||||
pass
|
||||
|
||||
def validate_kanban(self, barcode):
|
||||
'''
|
||||
"""
|
||||
It must return True if the kanban is valid, False otherwise
|
||||
:param barcode:
|
||||
:return:
|
||||
'''
|
||||
"""
|
||||
return True
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
Copyright 2017-2020 ForgeFlow, S.L.
|
||||
Copyright 2017 Creu Blanca
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="wizard_stock_request_kanban_form" model="ir.ui.view">
|
||||
<field name="name">wizard.stock.request.kanban.form</field>
|
||||
<field name="model">wizard.stock.request.kanban</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add Kanban">
|
||||
<div class="alert alert-success text-center o_form_header"
|
||||
role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '!=', 0)]}">
|
||||
<bold><field name="status"/></bold>
|
||||
<div
|
||||
class="alert alert-success text-center o_form_header"
|
||||
role="alert"
|
||||
style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '!=', 0)]}"
|
||||
>
|
||||
<bold>
|
||||
<field name="status" />
|
||||
</bold>
|
||||
</div>
|
||||
<div class="alert alert-danger alert-dismissable text-center"
|
||||
role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '=', 0)]}">
|
||||
<bold><field name="status"/></bold>
|
||||
<div
|
||||
class="alert alert-danger alert-dismissable text-center"
|
||||
role="alert"
|
||||
style="margin-bottom:0px;"
|
||||
attrs="{'invisible':[('status_state', '=', 0)]}"
|
||||
>
|
||||
<bold>
|
||||
<field name="status" />
|
||||
</bold>
|
||||
</div>
|
||||
<field name="status_state" invisible="1"/>
|
||||
<field name="kanban_id" invisible="1"/>
|
||||
<field name="stock_request_id" invisible="1"/>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"
|
||||
invisible="1"/>
|
||||
<field name="status_state" invisible="1" />
|
||||
<field name="kanban_id" invisible="1" />
|
||||
<field name="stock_request_id" invisible="1" />
|
||||
<field name="_barcode_scanned" widget="barcode_handler" />
|
||||
<footer>
|
||||
<button
|
||||
name="action_cancel"
|
||||
@@ -39,12 +45,11 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="wizard_stock_request_kanban_action"
|
||||
<act_window
|
||||
id="wizard_stock_request_kanban_action"
|
||||
name="Add Kanban"
|
||||
res_model="wizard.stock.request.kanban"
|
||||
view_mode="form"
|
||||
view_type="form"
|
||||
target="new"/>
|
||||
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
# Copyright 2017 Creu Blanca
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2017-2020 ForgeFlow, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import _, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class WizardStockRequestOrderKanban(models.TransientModel):
|
||||
_name = "wizard.stock.request.order.kanban"
|
||||
_description = "Stock Request Order Kanban Wizard"
|
||||
_inherit = "wizard.stock.request.kanban"
|
||||
|
||||
order_id = fields.Many2one(
|
||||
'stock.request.order',
|
||||
required=True
|
||||
)
|
||||
order_id = fields.Many2one("stock.request.order", required=True)
|
||||
|
||||
def validate_kanban(self, barcode):
|
||||
res = super().validate_kanban(barcode)
|
||||
@@ -23,30 +21,30 @@ class WizardStockRequestOrderKanban(models.TransientModel):
|
||||
self.status = _("Barcode %s is on the order") % barcode
|
||||
self.status_state = 1
|
||||
return False
|
||||
if self.order_id.state != 'draft':
|
||||
raise ValidationError(_(
|
||||
'Lines only can be added on orders with draft state'))
|
||||
if self.order_id.state != "draft":
|
||||
raise ValidationError(
|
||||
_("Lines only can be added on orders with draft state")
|
||||
)
|
||||
if not self.order_id.company_id:
|
||||
self.order_id.company_id = self.kanban_id.company_id
|
||||
elif self.order_id.company_id != self.kanban_id.company_id:
|
||||
raise ValidationError(_('Company must be the same'))
|
||||
raise ValidationError(_("Company must be the same"))
|
||||
if (
|
||||
self.kanban_id.procurement_group_id and
|
||||
self.order_id.procurement_group_id !=
|
||||
self.kanban_id.procurement_group_id
|
||||
and self.order_id.procurement_group_id
|
||||
!= self.kanban_id.procurement_group_id
|
||||
):
|
||||
raise ValidationError(_('Procurement group must be the same'))
|
||||
raise ValidationError(_("Procurement group must be the same"))
|
||||
if self.order_id.location_id != self.kanban_id.location_id:
|
||||
raise ValidationError(_('Location must be the same'))
|
||||
raise ValidationError(_("Location must be the same"))
|
||||
if self.order_id.warehouse_id != self.kanban_id.warehouse_id:
|
||||
raise ValidationError(_('Warehouse must be the same'))
|
||||
raise ValidationError(_("Warehouse must be the same"))
|
||||
return res
|
||||
|
||||
def stock_request_kanban_values(self):
|
||||
res = super().stock_request_kanban_values()
|
||||
res['order_id'] = self.order_id.id,
|
||||
res['expected_date'] = \
|
||||
fields.Datetime.to_string(self.order_id.expected_date),
|
||||
res["order_id"] = (self.order_id.id,)
|
||||
res["expected_date"] = fields.Datetime.to_string(self.order_id.expected_date)
|
||||
return res
|
||||
|
||||
def stock_request_ending(self):
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
Copyright 2017-2020 ForgeFlow, S.L.
|
||||
Copyright 2017 Creu Blanca
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="wizard_stock_request_order_kanban_form" model="ir.ui.view">
|
||||
<field name="name">wizard.stock.request.order.kanban.form</field>
|
||||
<field name="model">wizard.stock.request.order.kanban</field>
|
||||
<field name="mode">primary</field>
|
||||
<field name="inherit_id" ref="wizard_stock_request_kanban_form"/>
|
||||
<field name="inherit_id" ref="wizard_stock_request_kanban_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="kanban_id" position="after">
|
||||
<field name="order_id" invisible="1"/>
|
||||
<field name="order_id" invisible="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="wizard_stock_request_order_kanban_action"
|
||||
<act_window
|
||||
id="wizard_stock_request_order_kanban_action"
|
||||
name="Add Kanban"
|
||||
res_model="wizard.stock.request.order.kanban"
|
||||
view_mode="form"
|
||||
view_type="form"
|
||||
context="{'default_order_id': active_id}"
|
||||
target="new"/>
|
||||
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user