Skip to Content
Menu
This question has been flagged
2 Replies
2132 Views

Hello!


Has anyone ever needed yo change a project on a purchase order line, or several, once this has already been invoiced?

How can It be done?

Thanks you! 

Odoov15.




Avatar
Discard
Best Answer

If you Reset Invoice to Draft and then Cancel, you can change the purchase order line.  

It is also possible to change Analytic Account on the Vendor bill, if you reset it to draft.

Avatar
Discard
Best Answer

Hi,

The `product_id` field becomes read-only when the state is set to 'purchase'. Here's the condition that makes it read-only:

'readonly': [('state', 'in', ('purchase', 'to approve','done', 'cancel'))],

If you need to edit the `product_id` field after the state has been changed to 'purchase', you can achieve this by replacing the field with a new XML tag that has the same field name. This XML tag should not have the 'readonly' attribute set to restrict editing. This will allow you to modify the `product_id` field even when the state is 'purchase'.

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

        <field name="name">purchase.order.inherit.your.module</field>

        <field name="model">purchase.order</field>

        <field name="inherit_id" ref="purchase.purchase_order_form"/>

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

            <field name="product_id" position="replace">

                <field name="product_id"

                       attrs="{'required': [('display_type', '=', False)]}"

                       context="{'partner_id':parent.partner_id, 'quantity':product_qty,'uom':product_uom, 'company_id': parent.company_id}"

                       force_save="1"

                       domain="[('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/>

            </field>

        </field>

    </record>

Removing the 'readonly' attribute to allow editing of the `product_id` field after the state has changed to 'purchase' might introduce unintended or unwanted behavior. Carefully consider the implications of allowing edits in this state to ensure that it aligns with your business logic and requirements.


Hope it helps

Avatar
Discard

Please refrain from giving solutions that could potentially affect on someone's business data if you're not familiar with their specific context. Changing the product_id after stock moves are posted is a risky move, and it's vital to understand the business implications before making such suggestions. Let's prioritize responsible advice that respects the integrity of the data and business processes.

Related Posts Replies Views Activity
0
Aug 23
1099
1
Jul 22
97
1
May 24
1237
1
Nov 24
1872
1
Aug 23
2328