Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
157 Widoki

Hello

I am trying to customize the search more popup window in the the stock move / picking to add description_pickin field there for a meaningful product list which i believe should be the default behavior.

This is the code I am using in my custom module but it is not working.



class ProductProduct(models.Model):
    _inherit = 'product.product'

    description_pickingin = fields.Text(
        string='Picking In Description',
        related='product_tmpl_id.description_pickingin',
        readonly=True,
    )



class StockPicking(models.Model):
    _inherit = 'stock.picking'

    description_pickingin = fields.Text(
        string='Picking In Description',
        related='move_ids.description_pickingin', # Assuming you use move_ids
        readonly=True,
    )





and the following in the view:

        <record id="stock_picking_tree_view_with_pickingin" model="ir.ui.view">
            <field name="name">stock.picking.tree.with.pickingin</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='name']" position="after">
                     <field name="description_pickingin" optional="show"/>
                </xpath>
            </field>
        </record>

        <record id="stock_move_tree_view_with_pickingin" model="ir.ui.view">
            <field name="name">stock.move.tree.with.pickingin</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='name']" position="after">
                    <field name="description_pickingin" optional="show"/>
                </xpath>
            </field>
        </record>


This code is not showing what i ned.


appreciate your help in advance.



Awatar
Odrzuć
Autor Najlepsza odpowiedź

I have tried your code but same thing. nothing show up on the popup window.

What did you mean by:

 If you want to show it in “Search More,” make sure the field is in the tree view that opens in the popup.
Awatar
Odrzuć
Najlepsza odpowiedź

Hi,


Try the following.


1. Add field to stock.move.

   You probably want the product’s picking description (from product.product → product.template → description_pickingin):


class StockMove(models.Model):

    _inherit = 'stock.move'


    description_pickingin = fields.Text(

        string="Picking In Description",

        related="product_id.product_tmpl_id.description_pickingin",

        store=False,  # set store=True if you want to search/filter

        readonly=True,

    )


2. Update the View

    Now you can safely extend the stock move tree view:


<record id="stock_move_tree_view_with_pickingin" model="ir.ui.view">

    <field name="name">stock.move.tree.with.pickingin</field>

    <field name="model">stock.move</field>

    <field name="inherit_id" ref="stock.view_move_tree"/>

    <field name="arch" type="xml">

        <xpath expr="//field[@name='name']" position="after">

            <field name="description_pickingin" optional="show"/>

        </xpath>

    </field>

</record>



* You must define description_pickingin on stock.move, not stock.picking.

* Use a related field from product_id.product_tmpl_id.description_pickingin.

* Then inherit stock.view_move_tree to display it.

* If you want to show it in “Search More,” make sure the field is in the tree view that opens in the popup.



Hope it helps

Awatar
Odrzuć