Mig account_usability, sale_stock_usability, sale_usability, stock_usability

New module stock_account_usability
This commit is contained in:
Alexis de Lattre
2019-02-04 20:00:41 +01:00
parent 1a193dcbec
commit 9f1cf7af1e
39 changed files with 210 additions and 432 deletions

View File

@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (http://www.akretion.com)
# Copyright 2014-2019 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Stock Usability',
'version': '10.0.1.0.0',
'version': '12.0.1.0.0',
'category': 'Inventory, Logistic, Storage',
'license': 'AGPL-3',
'summary': 'Several usability enhancements in Warehouse management',

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2017-2019 Akretion France (https://akretion.com/)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Akretion (http://www.akretion.com)
# Copyright 2015-2019 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -10,28 +9,22 @@ import logging
logger = logging.getLogger(__name__)
class ProcurementOrder(models.Model):
_inherit = 'procurement.order'
class ProcurementGroup(models.Model):
_inherit = 'procurement.group'
@api.model
def _procure_orderpoint_confirm(
self, use_new_cursor=False, company_id=False):
logger.info(
'procurement scheduler: START to create procurements from '
'procurement scheduler: START to create moves from '
'orderpoints')
res = super(ProcurementOrder, self)._procure_orderpoint_confirm(
res = super(ProcurementGroup, self)._procure_orderpoint_confirm(
use_new_cursor=use_new_cursor, company_id=company_id)
logger.info(
'procurement scheduler: END creation of procurements from '
'procurement scheduler: END creation of moves from '
'orderpoints')
return res
# Why is this code in stock_usability and not in procurement_usability ?
# For a very good reason
# The stock module inherits run_scheduler(). So, if we want to have the
# START and END log message and a good end date
# for procurement.scheduler.log, the method below must be called first,
# so we must be "above" all modules that call run_scheduler()
@api.model
def run_scheduler(
self, use_new_cursor=False, company_id=False):
@@ -41,7 +34,7 @@ class ProcurementOrder(models.Model):
'(company ID=%d, uid=%d, use_new_cursor=%s)',
company_id, self._uid, use_new_cursor)
start_datetime = datetime.now()
res = super(ProcurementOrder, self).run_scheduler(
res = super(ProcurementGroup, self).run_scheduler(
use_new_cursor=use_new_cursor, company_id=company_id)
logger.info(
'END procurement scheduler '

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (http://www.akretion.com/)
Copyright 2015-2019 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -10,33 +10,11 @@
<record id="procurement_group_form_view" model="ir.ui.view">
<field name="name">stock_usability.procurement.group.form</field>
<field name="model">procurement.group</field>
<field name="inherit_id" ref="stock.procurement_group_form_view_herited"/>
<field name="inherit_id" ref="stock.procurement_group_form_view"/>
<field name="arch" type="xml">
<field name="move_type" position="after">
<field name="partner_id" readonly="True"/>
</field>
<xpath expr="//field[@name='move_type']/.." position="after">
<group name="picking" string="Pickings">
<field name="picking_ids" nolabel="1"/>
</group>
</xpath>
</field>
</record>
<record id="view_procurement_form_stock_inherit" model="ir.ui.view">
<field name="name">procurement_usability.procurement.order.form</field>
<field name="model">procurement.order</field>
<field name="inherit_id" ref="stock.view_procurement_form_stock_inherit"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='company_id']/.." position="after">
<group name="move_ids" string="Stock Moves" colspan="4">
<field name="move_ids" nolabel="1" readonly="True"/>
</group>
</xpath>
<field name="partner_dest_id" position="before">
<field name="orderpoint_id" readonly="1"/>
<field name="move_dest_id" groups="base.group_no_one" readonly="1"/>
</field>
</field>
</record>
@@ -61,6 +39,6 @@
<menuitem id="procurement_scheduler_log_menu"
action="procurement_scheduler_log_action"
parent="stock.menu_stock_sched" sequence="22"/>
parent="stock.menu_stock_inventory_control" sequence="50"/>
</odoo>

View File

@@ -3,5 +3,3 @@ access_procurement_scheduler_log_full,Full access on procurement.scheduler.log t
access_procurement_scheduler_log_user,Read/Create procurement.scheduler.log to Stock user,model_procurement_scheduler_log,stock.group_stock_user,1,0,1,0
access_procurement_scheduler_log_read,Read access on procurement.scheduler.log to Employee,model_procurement_scheduler_log,base.group_user,1,0,0,0
access_stock_warehouse_orderpoint_employee,Read access on stock.warehouse.orderpoint to employee (needed to open product form view with employee-only group),stock.model_stock_warehouse_orderpoint,base.group_user,1,0,0,0
stock.access_product_product_stock_user,product_product_stock_user,product.model_product_product,stock.group_stock_user,1,0,0,0
stock.access_product_template_stock_user,product.template stock user,product.model_product_template,stock.group_stock_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
3 access_procurement_scheduler_log_user Read/Create procurement.scheduler.log to Stock user model_procurement_scheduler_log stock.group_stock_user 1 0 1 0
4 access_procurement_scheduler_log_read Read access on procurement.scheduler.log to Employee model_procurement_scheduler_log base.group_user 1 0 0 0
5 access_stock_warehouse_orderpoint_employee Read access on stock.warehouse.orderpoint to employee (needed to open product form view with employee-only group) stock.model_stock_warehouse_orderpoint base.group_user 1 0 0 0
stock.access_product_product_stock_user product_product_stock_user product.model_product_product stock.group_stock_user 1 0 0 0
stock.access_product_template_stock_user product.template stock user product.model_product_template stock.group_stock_user 1 0 0 0

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (http://www.akretion.com)
# Copyright 2014-2019 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -9,11 +8,6 @@ import logging
logger = logging.getLogger(__name__)
class StockInventory(models.Model):
_inherit = 'stock.inventory'
_order = 'id desc'
class StockPicking(models.Model):
_inherit = 'stock.picking'
_order = 'id desc'
@@ -24,13 +18,6 @@ class StockPicking(models.Model):
picking_type_id = fields.Many2one(track_visibility='onchange')
move_type = fields.Selection(track_visibility='onchange')
@api.multi
def force_assign(self):
res = super(StockPicking, self).force_assign()
for pick in self:
pick.message_post(_("Using <b>Force Availability</b>!"))
return res
@api.multi
def do_unreserve(self):
res = super(StockPicking, self).do_unreserve()
@@ -39,18 +26,6 @@ class StockPicking(models.Model):
return res
class StockLocation(models.Model):
_inherit = 'stock.location'
name = fields.Char(translate=False)
# with the 'quant_ids' field below, you can for example search empty stock
# locations with self.env['stock.location'].search([
# ('child_ids', '=', False), ('quant_ids', '=', False),
# ('usage', '=', 'internal')])
quant_ids = fields.One2many(
'stock.quant', 'location_id', string="Related Quants")
class StockPickingType(models.Model):
_inherit = 'stock.picking.type'
@@ -94,14 +69,6 @@ class StockWarehouseOrderpoint(models.Model):
class StockMove(models.Model):
_inherit = 'stock.move'
# It seems that it is not necessary any more to
# have the digits= on these 2 fields to fix the bug
# https://github.com/odoo/odoo/pull/10038
# reserved_availability = fields.Float(
# digits=dp.get_precision('Product Unit of Measure'))
# availability = fields.Float(
# digits=dp.get_precision('Product Unit of Measure'))
@api.multi
def name_get(self):
'''name_get of stock_move is important for the reservation of the
@@ -117,38 +84,27 @@ class StockMove(models.Model):
if line.partner_id:
name = line.partner_id.name + ' ' + name
if line.date_expected:
date_expec_dt = fields.Datetime.from_string(line.date_expected)
name = name + ' ' + fields.Date.to_string(date_expec_dt)
name = name + ' ' + line.date_expected
res.append((line.id, name))
return res
def button_do_unreserve(self):
for move in self:
move.do_unreserve()
if move.picking_id:
product = move.product_id
self.picking_id.message_post(_(
"Product <a href=# data-oe-model=product.product "
"data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
% (product.id, product.display_name,
move.product_qty, move.product_id.uom_id.name))
ops = self.env['stock.pack.operation']
for smol in move.linked_move_operation_ids:
if smol.operation_id:
ops += smol.operation_id
ops.unlink()
# def button_do_unreserve(self):
# for move in self:
# move.do_unreserve()
# if move.picking_id:
# product = move.product_id
# self.picking_id.message_post(_(
# "Product <a href=# data-oe-model=product.product "
# "data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
# % (product.id, product.display_name,
# move.product_qty, move.product_id.uom_id.name))
# ops = self.env['stock.pack.operation']
# for smol in move.linked_move_operation_ids:
# if smol.operation_id:
# ops += smol.operation_id
# ops.unlink()
class StockIncoterms(models.Model):
_inherit = 'stock.incoterms'
@api.multi
def name_get(self):
res = []
for inco in self:
res.append((inco.id, u'[%s] %s' % (inco.code, inco.name)))
return res
class ProcurementGroup(models.Model):
_inherit = 'procurement.group'

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2014-2016 Akretion (http://www.akretion.com/)
Copyright 2014-2019 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -16,27 +16,15 @@
<field name="backorder_id" position="attributes">
<attribute name="attrs">{}</attribute>
</field>
<field name="min_date" position="after">
<field name="date_done" states="done"/>
</field>
<field name="partner_id" position="attributes">
<attribute name="context">{'show_address': 1}</attribute>
<attribute name="options">{'always_reload': True}</attribute>
</field>
<!-- Maybe it's usefull to always display stock pack operations...
or maybe only for debugging... I haven't decided yet !
<page string="Operations" position="attributes">
<attribute name="attrs"></attribute>
</page>
-->
<button name="action_cancel" type="object" position="attributes">
<attribute name="confirm">Are you sure you want to cancel this picking?</attribute>
</button>
<!-- This sum is useful to check the 'number of items' to transfer... -->
<xpath expr="//field[@name='pack_operation_product_ids']/tree/field[@name='product_qty']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
<xpath expr="//field[@name='pack_operation_product_ids']/tree/field[@name='qty_done']" position="attributes">
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom_qty']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
</field>
@@ -47,7 +35,7 @@
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.vpicktree" />
<field name="arch" type="xml">
<field name="min_date" position="after">
<field name="scheduled_date" position="after">
<field name="date_done"/>
</field>
</field>
@@ -58,17 +46,17 @@
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_internal_search" />
<field name="arch" type="xml">
<group expand="0" position="inside">
<filter string="Partner" context="{'group_by': 'partner_id'}"/>
</group>
<filter context="{'group_by':'origin'}" position="replace"/>
<filter context="{'group_by':'min_date'}" position="after">
<filter name="date_done" string="Date Done"
<filter name="picking_type" position="after">
<filter string="Partner" name="partner_groupby" context="{'group_by': 'partner_id'}"/>
</filter>
<filter name="origin" position="replace"/>
<filter name="expected_date" position="after">
<filter name="date_done_groupby" string="Date Done"
context="{'group_by': 'date_done:day'}"/>
</filter>
<filter context="{'group_by':'min_date'}" position="attributes">
<filter name="expected_date" position="attributes">
<!-- group per day -->
<attribute name="context">"{'group_by': 'min_date:day'}"</attribute>
<attribute name="context">"{'group_by': 'scheduled_date:day'}"</attribute>
</filter>
</field>
</record>
@@ -84,38 +72,43 @@
</record>
<record id="stock.action_picking_tree_all" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,pivot</field> <!-- add pivot -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.stock_picking_action_picking_type" model="ir.actions.act_window">
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree_done" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree_ready" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree_done_grouped" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree_waiting" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree_late" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree_backorder" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<record id="stock.action_picking_tree" model="ir.actions.act_window">
<field name="view_mode">tree,form,calendar,graph</field> <!-- add graph -->
<field name="view_mode">tree,kanban,form,calendar,pivot</field> <!-- add pivot -->
</record>
<!-- Display route in stock moves -->
<!--
<record id="view_move_form" model="ir.ui.view">
<field name="name">stock.usability.stock.move.form</field>
<field name="model">stock.move</field>
@@ -150,7 +143,9 @@
</group>
</field>
</record>
-->
<!--
<record id="view_move_picking_form" model="ir.ui.view">
<field name="name">stock.usability.stock.move.picking.form</field>
<field name="model">stock.move</field>
@@ -161,7 +156,7 @@
groups="stock.group_stock_user"
attrs="{'invisible': [('reserved_quant_ids', '=', [])]}"/>
</field>
<field name="group_id" position="replace"/> <!-- in stock, this field has invisible="1" re-add it below as visible -->
<field name="group_id" position="replace"/>
<group name="moved_quants_grp" position="after">
<notebook colspan="2">
<page string="Notes" name="notes">
@@ -184,6 +179,7 @@
</group>
</field>
</record>
-->
<record id="view_move_picking_tree" model="ir.ui.view">
<field name="name">stock_usability.src_location.in.picking.form</field>
@@ -196,13 +192,14 @@
<field name="location_dest_id" position="attributes">
<attribute name="invisible">0</attribute>
</field>
<!--
<field name="state" position="after">
<button type="object" name="button_do_unreserve" string="Unreserve"
groups="stock.group_stock_user"
attrs="{'invisible': [('reserved_quant_ids', '=', [])]}"
icon="fa-ban"/>
<field name="reserved_quant_ids" invisible="1"/>
</field>
</field> -->
</field>
</record>
@@ -223,20 +220,6 @@
</field>
</record>
<record id="view_pack_operation_lot_form" model="ir.ui.view">
<field name="name">stock_usability.stock.pack.operation.form</field>
<field name="model">stock.pack.operation</field>
<field name="inherit_id" ref="stock.view_pack_operation_lot_form" />
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="picking_source_location_id" invisible="1"/>
<field name="picking_destination_location_id" invisible="1"/>
<field name="location_id" domain="[('id', 'child_of', picking_source_location_id)]" groups="stock.group_stock_multi_locations"/>
<field name="location_dest_id" domain="[('id', 'child_of', picking_destination_location_id)]" groups="stock.group_stock_multi_locations"/>
</field>
</field>
</record>
<record id="view_warehouse" model="ir.ui.view">
<field name="name">stock.usability.warehouse.form</field>
<field name="model">stock.warehouse</field>
@@ -266,7 +249,7 @@
<field name="arch" type="xml">
<filter name="inactive" position="after">
<group string="Group By" name="groupby">
<filter name="usage" string="Location Type"
<filter name="usage_groupby" string="Location Type"
context="{'group_by': 'usage'}"/>
</group>
</filter>
@@ -314,51 +297,27 @@ should be able to access it. So I add a menu entry under Inventory Control. -->
<attribute name="decoration-info">product_qty &gt; theoretical_qty</attribute>
<attribute name="decoration-warning">product_qty &lt; theoretical_qty</attribute>
</xpath>
<button name="reset_real_qty" type="object" position="attributes">
<button name="action_reset_product_qty" type="object" position="attributes">
<attribute name="confirm">Are you sure you want to reset all quantities to 0 ?</attribute>
</button>
</field>
</record>
<record id="stock_location_route_view_search" model="ir.ui.view">
<field name="name">usability.stock.location.route.search</field>
<field name="model">stock.location.route</field>
<field name="inherit_id" ref="stock.stock_location_route_view_search"/>
<field name="arch" type="xml">
<filter name="inactive" position="before">
<field name="name"/>
</filter>
</field>
</record>
<record id="view_stock_quant_tree" model="ir.ui.view">
<field name="name">stock.usability.quant.tree</field>
<field name="model">stock.quant</field>
<field name="inherit_id" ref="stock.view_stock_quant_tree"/>
<field name="arch" type="xml">
<field name="reservation_id" position="attributes">
<attribute name="invisible">0</attribute>
<field name="quantity" position="attributes">
<attribute name="sum">1</attribute>
</field>
<field name="qty" position="attributes">
<attribute name="sum">Total Qty</attribute>
<field name="reserved_quantity" position="attributes">
<attribute name="sum">1</attribute>
</field>
</field>
</record>
<!--
<record id="view_template_property_form" model="ir.ui.view">
<field name="name">stock.usability.product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.view_template_property_form"/>
<field name="arch" type="xml">
<field name="virtual_available" position="before">
<field name="outgoing_qty"/>
</field>
</field>
</record>
-->
<!-- more detailed stock.move tree view when using the button from product form -->
<!-- TODO TEST
<record id="stock.act_product_stock_move_open" model="ir.actions.act_window">
@@ -376,7 +335,7 @@ So I create another "regular" Quants" menu entry -->
</record>
<menuitem id="stock_quant_menu" action="stock_quant_action"
parent="stock.menu_warehouse_report"
parent="stock.menu_stock_inventory_control"
sequence="135"/>
</odoo>