[IMP] stock_picking_batch_custom: order detailed ops by category, product, partner
Override _order on stock.move.line with stored Char fields so the server returns records in the correct order on initial load (default_order in the view only applies to interactive client-side sorting, not the initial fetch). Add product_name and partner_name stored related fields to avoid SQL JOINs in ORDER BY. Use the same fields in the view's default_order for consistency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8b9995526e
commit
f5670906f9
2 changed files with 16 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ from odoo import models
|
|||
|
||||
class StockMoveLine(models.Model):
|
||||
_inherit = "stock.move.line"
|
||||
_order = "product_categ_complete_name, product_name, partner_name, id"
|
||||
|
||||
product_categ_id = fields.Many2one(
|
||||
comodel_name="product.category",
|
||||
|
|
@ -24,6 +25,20 @@ class StockMoveLine(models.Model):
|
|||
readonly=True,
|
||||
)
|
||||
|
||||
product_name = fields.Char(
|
||||
string="Product Name",
|
||||
related="product_id.name",
|
||||
store=True,
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
partner_name = fields.Char(
|
||||
string="Partner Name",
|
||||
related="picking_id.partner_id.name",
|
||||
store=True,
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
product_default_code = fields.Char(
|
||||
string="Product Code",
|
||||
related="product_id.default_code",
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<field name="inherit_id" ref="stock_picking_batch.view_move_line_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//list" position="attributes">
|
||||
<attribute name="default_order">product_categ_complete_name,product_id,picking_partner_id</attribute>
|
||||
<attribute name="default_order">product_categ_complete_name,product_name,partner_name</attribute>
|
||||
<attribute name="class">o_batch_move_line_list</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='product_id']" position="before">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue