How to inherit and add new state on a default module in odoo? - odoo

i am using odoo 10. Here i want to add an extra state in purchase module.Current states are open,draft and done. I want to add another state named new. How can i achieve this?

Use selection_add attribute.
Try below code:
state = fields.Selecion(selection_add=[('new_state','New State')])
Hope this will help you.

Related

How to add new field to hr.employee.public [Odoo 14]

I'm a newbie to Odoo. I can add new field to hr.employee but fail on hr.employee.public. It shows
error psycopg2.ProgrammingError: column emp.onboarding_date does not exist.
Why Odoo cannot create new column in the case?
I would like to add onboarding_date to both hr.view_employee_form and hr.hr_employee_public_view_form.
Since Odoo V13:
Inherit from hr.employee.base instead of hr.employee. Related commit.

Update MKPF text during save in MB1A tcode

I am working on a requirement to update MKPF-BKTXT during save in MB1A tcode. I found MB_DOCUMENT_BADI, but the methods of the BADI only allows importing parameters and does not allow changing MKPF.
Has anyone in the community worked on similar? How to do this?
You can use BTE event 00001120 to do that and substitute BKTXT. Here is the detailed guide:
https://wiki.scn.sap.com/wiki/display/ERPFI/Example+for+BTE+00001120
Just create Product, register your custom FM as process module and code your substitution.

How can we make an Item in socialengine?

I know how to get an item of the particular table. Like for user we can have
$userItem = Engine_Api::_()->getItem("user", $userId);
or for a custom table
$customItem = Engine_Api::_()->getItem("custom", $customeId);
I want to know the code or method how can I make my $customItem to work the same way as $userItem works for users table. So that I can get data or manipulate the data of custom table
Thanks for your help. :-)
You can achieve that by creating a model. Check how it's done in /application/modules/User/Model. There is User.php file that declares User_Model_User and methods available for User such as getTitle, get Href etc.
You may use similar approach for your custom item. You will also need to create a file similar to /application/modules/User/Model/DbTable/User.php to declare table for your custom items.

Adding new field on Odoo Product Variant

I am trying to add new field to product.product model.
What I've done so far is:
Add new field on the following model (From Settings > Database Structure > Models):
product.product
with the following details:
Name: x_product_cost
Field Label: Product Cost
Field Type: Float
and leave the rest to default.
The problem is i am unable to show it on the form. This is the only code that is generated when I tried to edit Form:
View Name: product.product.form
Object: product.product
Inherited View: product.template.common.form
Product Variant
lst_price
I can't use product.template model, since that inherits to product.product
Am i missing something here?
PS: I am trying to temporarily fixed assign-different-cost-on-product-variant bug as specified here
https://github.com/odoo/odoo/issues/1198
Can anyone help me with this?
Actually instead of modifying the model from the Odoo configuration, you should create a custom module, in which you will add the new fields and the new behaviors that you need.
To do so you will have to inherit from the models in the python files to extend them, and you will surely have to modify the views as well, so that your custom fields get displayed.
For reference on how to extend models, create a custom module and create the views, you should refer to the Odoo documentation that you can find here.
As an additional note in case you didn't know, but their is a new API that appeared in the version 8 of Odoo, if you can use it, it is much easier and much nicer.

FM BAPI_PO_CHANGE how to add item?

I try to add items to existing PO.
And I use BAPI_PO_CHANGE.
Maybe somebody have WORKING example how to ADD item to PO?
I ALREADY CAN UPDATE EXISTING items in PO.
I need to add some NEW.
And yes, we talking about AFS system. :(((
Thanks in advance, Alexander.
Pass the relevent filed ON in the Xstrucuture for all the required fields.
E.g.
PO_ITEM-PO_ITEM = new_item
APPEND..
PO_ITEMx-PO_ITEM = new_item
PO_ITEMx-PO_ITEMX = 'X'.
APPEND ...
Try BAPI_PO_CREATE1 it will handle the AFS data needs as well. You should be able to open an existing PO and add a NEW item to that existing PO. PO_CHANGE will only allow changes to existing items. I have not used these in some time, but you can get a better idea of how SAP uses BAPI's by tracing some of the logic within as you develop your programming.