Closed MeriemBo closed 7 years ago
just put something like ['post'] in the args,
Thank you , I tried it:
self.odooRPC.call('project.project', 'create',['posts'] , {'fields': ['new project']})
.then((projects:any) => {
if(projects){
self.projectList = projects;
but it's not working !
post your angular error, and check in odoo log, post it here,
error_handler.js:54 EXCEPTION: Uncaught (in promise): Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 648, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 685, in dispatch
result = self._call_function(self.params)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, *kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
return f(dbname, args, kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 964, in call
return self.method(*args, *kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 514, in response_wrap
response = f(args, kw)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 888, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 880, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, *kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 250, in wrapper
return old_api(self, args, **kwargs)
TypeError: create() got an unexpected keyword argument 'fields'
i see you got wrong syntax, what do you want to achieve? is it create? if it is, it should be like this self.odooRPC.call('project.project', 'create',[{name':this.controlname.controls['name'].value}] , {})
Yes , I want to add a project to Odoo , what does controlname refers to please ? can you give me a concrete example , for creating a project called : New project for example ?
are you familiar with angular2? if not you should learn the basic first, like form, https://scotch.io/tutorials/using-angular-2s-model-driven-forms-with-formgroup-and-formcontrol control name in that example i gave refer to the form control name that you use in your form
I m not using any form , I want the project to be added in the odoo backend , not filling some kinf of forms in my app :/ !
Do you have any ideas about that ?
yes actually the basic process should be either one of the process (CRUD), which process do you want to do?
it is a CRUD app , I just wanted to test , and see if I can directly add a project in Odoo uding this script . I was able to write in the odoo BD but using another piece of code , another package , so it's possible, I just need to figure out how to use the method call and create here.
ok i see, then what you want to do is, self.odooRPC.call('project.project', 'create',[{name':'your_project_name'] , {}) where name is the "name" field in your odoo project object and "your_project_name" is your value for that field, if you want to add more than one field just put "," symbol
All right , thank you , but are you sure about the syntax because it's causing me errors all over the code :/ !
This worked , thank you so much :) !
self.odooRPC.call('project.project', 'create',[{name:'New'}] , {}) .then((projects:any) => { if(projects){ self.projectList = projects; }
hi @MeriemBo could you please close this case? if its already solved.
I want to create a new project in Odoo via my app , I tried this code :
import { Component, OnInit } from '@angular/core'; import { OdooRPCService } from 'angular2-odoo-jsonrpc'; import { Http} from '@angular/http'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], providers: [OdooRPCService] }) export class AppComponent implements OnInit{
projectList; ngOnInit(){ let self = this; self.projectList = []; self.odooRPC.init({ odoo_server: "https://demo" }); self.odooRPC.login('DB', 'admin', 'admin').then(res => { console.log('login success'); }).catch( err => { console.error('login failed', err); }) self.odooRPC.call('project.project', 'create',"" ,{ 'name' :'New project'}) .then((projects:any) => { if(projects){ self.projectList = projects; } }) } constructor( private odooRPC: OdooRPCService){ }} But it's not working , I don't know what to put in the *args :/ , any help ?