Odoo Help


3 Answers

Ray Carnes

--Ray Carnes--
| 10 7 11
Greater Los Angeles, Stati Uniti d'America
--Ray Carnes--

Business Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0, 11.0 and 12.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
06/12/17, 14:38

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.

Malik Sikandar Hayat
07/12/17, 01:24

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.


Malik Sikandar Hayat
09/12/17, 07:54

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

mahmood fawzi
09/12/17, 06:11

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


1 Comment
Malik Sikandar Hayat
09/12/17, 07:52

True that was mistake. thanks

Ask a Question
Keep Informed
2 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now