This question has been flagged
3 Replies
10569 Views

Hi,

Is there a way we can move analytical account and tag in the PO header instead of line. In lengthy PO same values are need to be selected for each line to avoid this if we can move in header or create custom in header and assign value to lines. Kindly share possible solution. thanks

Avatar
Discard

Hello,

It was working perfectly in V12 but does not seem to work anymore in V13?

Any feedback?

Thanks

I just tried this at v13. It still works. Please retrace your steps and if you are having problems, create a NEW question that links to this one, sharing your steps with more detail than "does not seem to work" as it is very challenging to know what the problem is: Does the field show on the screen? Can you select an Account? Does the Analytic Account field show on the line? Does a value get populated? Does the incorrect value get populated? Is there any error? etc.

With the same setup ... the field analytic account on the order line does not populate In V13 even if it was well the case in the V12. Same DB just migrated in V13

It works in V13 if we do the update directly in the form view of the PO... If I try to do the update the context of the order line via Studio like in V12 it does not work however... Whatever it still works via the form view update.

Best Answer

1. Create a new field on the Purchase Order model to store the Analytic Account Default:



2. Add this new field to the Purchase Order view:

(You would create your own view that inherits the standard view and add the new field at the position you like):

<field name="x_account_analytic_account"/>


3. Set the context for the order_line field so that it picks up the value selected in the new field:

context="{'default_account_analytic_id': x_account_analytic_account,}"


4. As soon as you Add an Item on the Purchase Order, the account_analytic_id field on the Purchase Order Line will be populated:

 


You can do the same for the analytic_tag_ids field.

Avatar
Discard
Author

Hi Ray Carnes,

Excellent demonstration of the point but seems I am missing something as tried on both community and enterprise but getting error when I click in the lines analytic filed as nothing getting defaulted,

Uncaught Error: NameError: name 'x_account_analytic_account' is not defined

View changes,

<field name="partner_ref"/>

<field name="x_account_analytic_account"/>

<field name="currency_id" groups="base.group_multi_currency"/>

<field name="is_shipped" invisible="1"/>

<field name="account_analytic_id" context="{'default_account_analytic_id': x_account_analytic_account,}" groups="purchase.group_analytic_accounting"/>

Few points need to clear,

1- this filed should be created under which model purchase order or purchase order line?

2 - context="{'default_account_analytic_id': x_account_analytic_account,}" << this comma should be there or should be removed?

3- the field already having one context so how to add another,

<field name="account_analytic_id" context="{'default_partner_id':parent.partner_id}" groups="purchase.group_analytic_accounting"/>

I think I am missing something may be very small change will solve the problem. I have both enterprise and community versions.

thanks

Author

I was missing this "Set the context for the order_line field". thanks

Best Answer

Any idea of how to do this on Odoo enterprise 16?

Thanks

Avatar
Discard

Did you get any solution?

Best Answer

Dear Mr. Sikandar

the context should be in the order_line field not in the analytic_account field the below code should be there:

<field name="order_line" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" context="{'default_account_analytic_id': x_account_analytic_account}">

the code has been tested and its working perfect,

thanks Mr. Ray

                         

Avatar
Discard
Author

True that was mistake. thanks