[IMP] pre-commit: first run on whole repo
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
|
||||
|
||||
{
|
||||
'name': 'Sale Stock Usability',
|
||||
'version': '14.0.1.0.0',
|
||||
'category': 'Sales Management',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Small usability improvements to the sale_stock module',
|
||||
'description': """
|
||||
"name": "Sale Stock Usability",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "Sales Management",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Small usability improvements to the sale_stock module",
|
||||
"description": """
|
||||
Sale Stock Usability
|
||||
====================
|
||||
|
||||
@@ -19,14 +19,14 @@ The usability enhancements include:
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['sale_stock'],
|
||||
'data': [
|
||||
'views/sale_order.xml',
|
||||
'views/procurement_group.xml',
|
||||
'views/stock_move.xml',
|
||||
'views/stock_picking.xml',
|
||||
],
|
||||
'installable': True,
|
||||
"author": "Akretion",
|
||||
"website": "https://github.com/OCA/odoo-usability",
|
||||
"depends": ["sale_stock"],
|
||||
"data": [
|
||||
"views/sale_order.xml",
|
||||
"views/procurement_group.xml",
|
||||
"views/stock_move.xml",
|
||||
"views/stock_picking.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -7,20 +7,24 @@ from odoo.tools import float_compare, float_round
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
_inherit = "sale.order"
|
||||
|
||||
warehouse_id = fields.Many2one(tracking=True)
|
||||
incoterm = fields.Many2one(tracking=True)
|
||||
picking_status = fields.Selection([
|
||||
('delivered', 'Fully Delivered'),
|
||||
('partially_delivered', 'Partially Delivered'),
|
||||
('to_deliver', 'To Deliver'),
|
||||
('cancel', 'Delivery Cancelled'),
|
||||
('no', 'Nothing to Deliver')
|
||||
], string='Picking Status', compute='_compute_picking_status',
|
||||
store=True)
|
||||
picking_status = fields.Selection(
|
||||
[
|
||||
("delivered", "Fully Delivered"),
|
||||
("partially_delivered", "Partially Delivered"),
|
||||
("to_deliver", "To Deliver"),
|
||||
("cancel", "Delivery Cancelled"),
|
||||
("no", "Nothing to Deliver"),
|
||||
],
|
||||
string="Picking Status",
|
||||
compute="_compute_picking_status",
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.depends('state', 'picking_ids.state')
|
||||
@api.depends("state", "picking_ids.state")
|
||||
def _compute_picking_status(self):
|
||||
"""
|
||||
Compute the picking status for the SO. Possible statuses:
|
||||
@@ -34,40 +38,46 @@ class SaleOrder(models.Model):
|
||||
cancel state.
|
||||
"""
|
||||
for order in self:
|
||||
picking_status = 'no'
|
||||
if order.state in ('sale', 'done') and order.picking_ids:
|
||||
pstates = [
|
||||
picking.state for picking in order.picking_ids]
|
||||
if all([state == 'cancel' for state in pstates]):
|
||||
picking_status = 'cancel'
|
||||
elif all([state in ('done', 'cancel') for state in pstates]):
|
||||
picking_status = 'delivered'
|
||||
elif any([state == 'done' for state in pstates]):
|
||||
picking_status = 'partially_delivered'
|
||||
elif all([
|
||||
state in ('confirmed', 'assigned', 'waiting', 'cancel')
|
||||
for state in pstates]):
|
||||
picking_status = 'to_deliver'
|
||||
picking_status = "no"
|
||||
if order.state in ("sale", "done") and order.picking_ids:
|
||||
pstates = [picking.state for picking in order.picking_ids]
|
||||
if all([state == "cancel" for state in pstates]):
|
||||
picking_status = "cancel"
|
||||
elif all([state in ("done", "cancel") for state in pstates]):
|
||||
picking_status = "delivered"
|
||||
elif any([state == "done" for state in pstates]):
|
||||
picking_status = "partially_delivered"
|
||||
elif all(
|
||||
[
|
||||
state in ("confirmed", "assigned", "waiting", "cancel")
|
||||
for state in pstates
|
||||
]
|
||||
):
|
||||
picking_status = "to_deliver"
|
||||
order.picking_status = picking_status
|
||||
|
||||
def report_qty_to_deliver(self):
|
||||
# Can be useful for delivery report
|
||||
self.ensure_one()
|
||||
res = []
|
||||
prec = self.env['decimal.precision'].precision_get(
|
||||
'Product Unit of Measure')
|
||||
prec = self.env["decimal.precision"].precision_get("Product Unit of Measure")
|
||||
for line in self.order_line:
|
||||
if (
|
||||
line.product_id.type in ('product', 'consu') and
|
||||
float_compare(
|
||||
line.product_uom_qty, line.qty_delivered,
|
||||
precision_digits=prec) > 0):
|
||||
line.product_id.type in ("product", "consu")
|
||||
and float_compare(
|
||||
line.product_uom_qty, line.qty_delivered, precision_digits=prec
|
||||
)
|
||||
> 0
|
||||
):
|
||||
qty_to_deliver = float_round(
|
||||
line.product_uom_qty - line.qty_delivered, precision_digits=prec)
|
||||
res.append({
|
||||
'product': line.product_id,
|
||||
'name': line.name,
|
||||
'uom': line.product_uom,
|
||||
'qty_to_deliver': qty_to_deliver,
|
||||
})
|
||||
line.product_uom_qty - line.qty_delivered, precision_digits=prec
|
||||
)
|
||||
res.append(
|
||||
{
|
||||
"product": line.product_id,
|
||||
"name": line.name,
|
||||
"uom": line.product_uom,
|
||||
"qty_to_deliver": qty_to_deliver,
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="procurement_group_form_view" model="ir.ui.view">
|
||||
<field name="name">sale_stock_usability.procurement.group.form</field>
|
||||
<field name="model">procurement.group</field>
|
||||
<field name="inherit_id" ref="stock.procurement_group_form_view"/>
|
||||
<field name="inherit_id" ref="stock.procurement_group_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="move_type" position="after">
|
||||
<field name="sale_id"/>
|
||||
<field name="sale_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="view_order_form" model="ir.ui.view">
|
||||
<field name="name">sale_stock_usability.order.form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale_stock.view_order_form_inherit_sale_stock"/>
|
||||
<field name="inherit_id" ref="sale_stock.view_order_form_inherit_sale_stock" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="picking_policy" position="after">
|
||||
<field name="picking_status"/>
|
||||
<field name="picking_status" />
|
||||
</field>
|
||||
<!-- move warehouse_id to the top, not hidden in the 2nd tab -->
|
||||
<group name="order_details" position="inside">
|
||||
<field name="warehouse_id" options="{'no_create': True}" groups="stock.group_stock_multi_warehouses" force_save="1" position="move"/>
|
||||
<field
|
||||
name="warehouse_id"
|
||||
options="{'no_create': True}"
|
||||
groups="stock.group_stock_multi_warehouses"
|
||||
force_save="1"
|
||||
position="move"
|
||||
/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
@@ -25,10 +30,18 @@
|
||||
<record id="view_order_tree" model="ir.ui.view">
|
||||
<field name="name">sale_stock_usability.order.tree</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||
<field name="inherit_id" ref="sale.view_order_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice_status" position="before">
|
||||
<field name="picking_status" decoration-success="picking_status == 'delivered'" decoration-info="picking_status == 'to_deliver'" decoration-warning="picking_status == 'partially_delivered'" decoration-danger="picking_status == 'cancel'" widget="badge" optional="show"/>
|
||||
<field
|
||||
name="picking_status"
|
||||
decoration-success="picking_status == 'delivered'"
|
||||
decoration-info="picking_status == 'to_deliver'"
|
||||
decoration-warning="picking_status == 'partially_delivered'"
|
||||
decoration-danger="picking_status == 'cancel'"
|
||||
widget="badge"
|
||||
optional="show"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -36,15 +49,21 @@
|
||||
<record id="view_sales_order_filter" model="ir.ui.view">
|
||||
<field name="name">sale_stock_usability.order.search</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
|
||||
<field name="inherit_id" ref="sale.view_sales_order_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="my_sale_orders_filter" position="after">
|
||||
<separator/>
|
||||
<filter string="Not Fully Delivered" name="not_fully_delivered"
|
||||
domain="[('picking_status', 'in', ('to_deliver', 'partially_delivered'))]"/>
|
||||
<filter string="Fully Delivered" name="fully_delivered"
|
||||
domain="[('picking_status', '=', 'delivered')]"/>
|
||||
<separator/>
|
||||
<separator />
|
||||
<filter
|
||||
string="Not Fully Delivered"
|
||||
name="not_fully_delivered"
|
||||
domain="[('picking_status', 'in', ('to_deliver', 'partially_delivered'))]"
|
||||
/>
|
||||
<filter
|
||||
string="Fully Delivered"
|
||||
name="fully_delivered"
|
||||
domain="[('picking_status', '=', 'delivered')]"
|
||||
/>
|
||||
<separator />
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="view_move_form" model="ir.ui.view">
|
||||
<field name="name">sale_stock_usability.stock_move.form</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_form"/>
|
||||
<field name="inherit_id" ref="stock.view_move_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="origin" position="after">
|
||||
<field name="sale_line_id" readonly="1"/>
|
||||
<field name="sale_line_id" readonly="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2015-2020 Akretion France (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="view_picking_form" model="ir.ui.view">
|
||||
<field name="name">sale_stock_usability.stock.picking.form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="inherit_id" ref="stock.view_picking_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="group_id" position="before">
|
||||
<field name="sale_id" readonly="1"/>
|
||||
<field name="sale_id" readonly="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user