sale_order_route: fix crash upon module installation and add route_id in sale.report
sale_stock_usability: direct access to warehouse_id in the sale.report pivot view
This commit is contained in:
@@ -16,7 +16,7 @@ This module has been written by Alexis de Lattre from Akretion
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['sale_stock', 'base_view_inheritance_extension'],
|
||||
'data': ['views/sale_order.xml'],
|
||||
'depends': ['sale_stock'],
|
||||
'data': ['views/sale_order.xml', 'views/sale_report.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from . import sale_order
|
||||
from . import sale_report
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
@@ -24,3 +24,18 @@ class SaleOrder(models.Model):
|
||||
lambda l:
|
||||
l.product_id and l.product_id.type in ('product', 'consu')).write(vals)
|
||||
return super()._action_confirm()
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = 'sale.order.line'
|
||||
|
||||
# It's important when you add a line AFTER order confirmation
|
||||
route_id = fields.Many2one(compute='_compute_route_id', readonly=False, store=True, precompute=True)
|
||||
|
||||
@api.depends('display_type', 'product_id')
|
||||
def _compute_route_id(self):
|
||||
for line in self:
|
||||
if not line.display_type and line.product_id and line.product_id.type in ('product', 'consu'):
|
||||
line.route_id = line.order_id.route_id or False
|
||||
else:
|
||||
line.route_id = False
|
||||
|
||||
21
sale_order_route/models/sale_report.py
Normal file
21
sale_order_route/models/sale_report.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2024 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class SaleReport(models.Model):
|
||||
_inherit = "sale.report"
|
||||
|
||||
route_id = fields.Many2one('stock.route', string='Route', readonly=True)
|
||||
|
||||
def _select_additional_fields(self):
|
||||
res = super()._select_additional_fields()
|
||||
res['route_id'] = "s.route_id"
|
||||
return res
|
||||
|
||||
def _group_by_sale(self):
|
||||
res = super()._group_by_sale()
|
||||
res += ', s.route_id'
|
||||
return res
|
||||
@@ -15,11 +15,6 @@
|
||||
<field name="partner_shipping_id" position="after">
|
||||
<field name="route_id" options="{'no_create_edit': True}"/>
|
||||
</field>
|
||||
<!-- propagate route_id to lines: it's important when you add an order line AFTER
|
||||
order confirmation -->
|
||||
<field name="order_line" position="attributes">
|
||||
<attribute name="context" operation="python_dict" key="default_route_id">route_id</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
20
sale_order_route/views/sale_report.xml
Normal file
20
sale_order_route/views/sale_report.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2024 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_product_search" model="ir.ui.view">
|
||||
<field name="model">sale.report</field>
|
||||
<field name="inherit_id" ref="sale.view_order_product_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<filter name="status" position="after">
|
||||
<filter string="Route" name="route_id_groupby" context="{'group_by':'route_id'}"/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -24,6 +24,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'depends': ['sale_stock'],
|
||||
'data': [
|
||||
'views/sale_order.xml',
|
||||
'views/sale_report.xml',
|
||||
'views/procurement_group.xml',
|
||||
'views/stock_move.xml',
|
||||
'views/stock_picking.xml',
|
||||
|
||||
20
sale_stock_usability/views/sale_report.xml
Normal file
20
sale_stock_usability/views/sale_report.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2024 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_product_search" model="ir.ui.view">
|
||||
<field name="model">sale.report</field>
|
||||
<field name="inherit_id" ref="sale.view_order_product_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<filter name="status" position="after">
|
||||
<filter string="Warehouse" name="warehouse_id_groupby" context="{'group_by':'warehouse_id'}"/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user