complex Bean IO record ,multi segments (0-n occurences) pipe delimited - bean-io

I have a scenario to map user information to Map of Objects (Map or List).
I have say user info as follows
CommonHeader(CX) block followed by 0 or more ID blocks followed by 0 or more Address blocks
Below are valid formats for user records
CX|19981222|19981222|ID|DriversLicence|111111111|ID|Passport|ABC12345|AD|123 Main Street|Atlanta|GA|30316|AD|100 PeachTree RD|Atlanta|Ga|3007|
CX|19981222|19981222|ID|DriversLicence|111111111|ID|Passport|ABC12345|
CX|19981222|19981222|AD|123 Main Street|Atlanta|GA|30316|AD|100 PeachTree RD|Atlanta|Ga|3007|
Is it possible to map such scenarios using beanio ?
Whats the best solution to handle these cases ?
I am using Beanio-2.1
My beanio mapping file is as follows
<stream name="userrRecord" format="delimited">
<parser>
<property name="delimiter" value="|"/>
</parser>
<record name="urecord" class="map" minOccurs="0" maxOccurs="unbounded" >
<segment name="CX" class="map">
<field name="CX"/>
<field name="DateFirstReported" type="date" format="yyyyMMdd"/>
<field name="DateLastReported" type="date" format="yyyyMMdd"/>
</segment>
<segment name="ID" class="map" minOccurs="0" maxOccurs="unbounded" collection="list">
<field name="ID"/>
<field name="IDType"/>
<field name="DocumentID"/>
</segment>
< segment name="AD" class="map" minOccurs="0" maxOccurs="unbounded" collection="list">
<field name="AD"/>
<field name="Street"/>
<field name="City"/>
<field name="State"/>
<field name="Zipcode"/>
</segment>
</record>
</stream>
When I try to unmarshall a record with 2 ID segmenst and 0 AD segments running into InvalidRecord exception.
Any help is highly appreciated.

I think this is not possible, as stated in the BeanIO Reference Guide:
Flat file formats (CSV, delimited and fixed length) may only contain one
field or segment of indeterminate length (i.e. where maxOccurs is greater
than minOccurs). The position of components that follow are assumed to be
relative to the end of the record.

You should change each of your segments to a separate record, and wrap it in a group. Then your sample input will look like this:
CX|19981222|19981222|
ID|DriversLicence|111111111|
ID|Passport|ABC12345|
AD|123 Main Street|Atlanta|GA|30316|
AD|100 PeachTree RD|Atlanta|Ga|3007|
CX|19981222|19981222|
ID|DriversLicence|111111111|
ID|Passport|ABC12345|
CX|19981222|19981222|
AD|123 Main Street|Atlanta|GA|30316|
AD|100 PeachTree RD|Atlanta|Ga|3007|
And your mapping like this:
<stream name="userrRecord" format="delimited">
<parser>
<property name="delimiter" value="|"/>
</parser>
<group name="urecord" class="map" minOccurs="0" maxOccurs="unbounded">
<record name="CX" class="map">
<field name="CX"/>
<field name="DateFirstReported" type="date" format="yyyyMMdd"/>
<field name="DateLastReported" type="date" format="yyyyMMdd"/>
</record>
<record name="ID" class="map" minOccurs="0" maxOccurs="unbounded" collection="list">
<field name="ID"/>
<field name="IDType"/>
<field name="DocumentID"/>
</record>
<record name="AD" class="map" minOccurs="0" maxOccurs="unbounded" collection="list">
<field name="AD"/>
<field name="Street"/>
<field name="City"/>
<field name="State"/>
<field name="Zipcode"/>
</record>
</group>
</stream>

Related

how to add field to product.template in odoo 12

I would like to display a field in Form View of the product module, here is the python file (i use odoo 12.):
class ClassProductInherited:
_inherit = 'product.template'
file = fields.Char(string="Choose File")
Here is xml code (i use odoo 12.):
<record id="view_product_form_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[#name='inventory']/group" position="before">
<group col="2" colspan="2">
<field name="file"/>
</group>
</xpath>
</field>
</record>
When I restart the server, problem is that I have the following error:
File "/home/odoo/models.py", line 1112, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.tools.convert.ParseError: "Error while validating constraint
Field `file` does not exist
Error context:
View `product.template.common.form.inherit`
[view_id: 2095, xml_id: module.view_product_form_inherit, model: product.template, parent_id: 402]
None" while parsing /home/omar/odoo/custom-addons/addons12/module/views/views.xml:403, near
<record id="view_product_form_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[#name='inventory']/group" position="before">
<group col="2" colspan="2">
<field name="file"/>
</group>
</xpath>
</field>
</record>
1- First, check if the manifest.py file contains:
"depends": [
'product'
],
2- check if the name of your file that contains the class ClassProductInherited: exists in the init.py file like this for example:
from . import my_file
<record id="view_product_form_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='weight']" position="before">
<group>
<field name="file"/>
</group>
</xpath>
</field>
</record>
Try this piece of code and let me know if it works.
check in your .py file that you have to inherit only single module in one ... if you declare more than one module in single record so remove it. and make another record for another module. then after check it you declare or note the field file in your .py file

odoo workflow not working, following odoo 10 documentation

i am following the odoo 10 workflow documentation tutorial and i was unable to get any response form clicking on the workflow buttons, no error is showing.
*please note that in my code the name of the module i am developing is "testModule" which is written as "test_module" inside python instead of "openacademy" that is used in the docs tutorial. and the view file is views.xml instead of openacademy.xml , could any of that have an impact?
views.xml
...
<!-- this is the sessions views -->
<!-- session form view -->
<record model="ir.ui.view" id="session_form_view">
<field name="name">session.form</field>
<field name="model">test_module.session</field>
<field name="arch" type="xml">
<form string="Session Form">
<header>
<button name="draft" type="workflow"
string="Reset to draft"
states="confirmed,done"/>
<button name="confirm" type="workflow"
string="Confirm" states="draft"
class="oe_highlight"/>
<button name="done" type="workflow"
string="Mark as done" states="confirmed"
class="oe_highlight"/>
<field name="state" widget="statusbar"/>
</header>
...
session_workflow.xml
<odoo>
<data>
<record model="workflow" id="wkf_session">
<field name="name">OpenAcademy sessions workflow</field>
<field name="osv">test_module.session</field>
<field name="on_create">True</field>
</record>
<record model="ir.actions.server" id="set_session_to_draft">
<field name="name">Set session to Draft</field>
<field name="model_id" ref="model_test_module_session"/>
<field name="code">
model.search([('id', 'in', context['active_ids'])]).action_draft()
</field>
</record>
<record model="workflow.activity" id="draft">
<field name="name">Draft</field>
<field name="wkf_id" ref="wkf_session"/>
<field name="flow_start" eval="True"/>
<field name="kind">dummy</field>
<field name="action"></field>
<field name="action_id" ref="set_session_to_draft"/>
</record>
<record model="ir.actions.server" id="set_session_to_confirmed">
<field name="name">Set session to Confirmed</field>
<field name="model_id" ref="model_test_module_session"/>
<field name="code">
model.search([('id', 'in', context['active_ids'])]).action_confirm()
</field>
</record>
<record model="workflow.activity" id="confirmed">
<field name="name">Confirmed</field>
<field name="wkf_id" ref="wkf_session"/>
<field name="kind">dummy</field>
<field name="action"></field>
<field name="action_id" ref="set_session_to_confirmed"/>
</record>
<record model="ir.actions.server" id="set_session_to_done">
<field name="name">Set session to Done</field>
<field name="model_id" ref="model_test_module_session"/>
<field name="code">
model.search([('id', 'in', context['active_ids'])]).action_done()
</field>
</record>
<record model="workflow.activity" id="done">
<field name="name">Done</field>
<field name="wkf_id" ref="wkf_session"/>
<field name="kind">dummy</field>
<field name="action"></field>
<field name="action_id" ref="set_session_to_done"/>
</record>
<record model="workflow.transition" id="session_draft_to_confirmed">
<field name="act_from" ref="draft"/>
<field name="act_to" ref="confirmed"/>
<field name="signal">confirm</field>
</record>
<record model="workflow.transition" id="session_confirmed_to_draft">
<field name="act_from" ref="confirmed"/>
<field name="act_to" ref="draft"/>
<field name="signal">draft</field>
</record>
<record model="workflow.transition" id="session_done_to_draft">
<field name="act_from" ref="done"/>
<field name="act_to" ref="draft"/>
<field name="signal">draft</field>
</record>
<record model="workflow.transition" id="session_confirmed_to_done">
<field name="act_from" ref="confirmed"/>
<field name="act_to" ref="done"/>
<field name="signal">done</field>
</record>
<record model="workflow.transition" id="session_auto_confirm_half_filled">
<field name="act_from" ref="draft"/>
<field name="act_to" ref="confirmed"/>
<field name="condition">taken_seats > 50</field>
</record>
</data>
inculded the call in manafest.py
'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
'views/templates.xml',
'views/partner.xml',
'views/session_workflow.xml',
],
created the fields and functions in my sessions model in models.py
state = fields.Selection([
('draft', "Draft"),
('confirmed', "Confirmed"),
('done', "Done"),
])
#api.multi
def action_draft(self):
self.state = 'draft'
#api.multi
def action_confirm(self):
self.state = 'confirmed'
#api.multi
def action_done(self):
self.state = 'done'
and at the end i upgraded the module
This happens with Sessions you created before implementing the session_workflow.xml
It should work fine for sessions you create after implementing the session_workflow.xml. They placed a warning for it somewhere in the middle of the example.
Warning
A workflow associated with a model is only created when the model's
records are created. Thus there is no workflow instance associated
with session instances created before the workflow's definition

Getting a JSONParseException when indexing fields from MongoDB collection in SOLR using DataImportHandler

I am seeing this exception while I am trying to index data from MongoDB collection :
Exception while processing: products document : SolrInputDocument(fields: []):org.apache.solr.handler.dataimport.DataImportHandlerException: com.mongodb.util.JSONParseException:
{idStr,name,code,description,price,brand,size,color}
^
at org.apache.solr.handler.dataimport.MongoEntityProcessor.initQuery(MongoEntityProcessor.java:46)
at org.apache.solr.handler.dataimport.MongoEntityProcessor.nextRow(MongoEntityProcessor.java:54)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:244)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:476)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:415)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:481)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:462)
Caused by: com.mongodb.util.JSONParseException:
{idStr,name,code,description,price,brand,size,color}
^
at com.mongodb.util.JSONParser.parseString(JSON.java:387)
Following is my data-source-config file in dataimport directory in conf folder of my core :
<dataConfig>
<dataSource name="mymongodb" type="MongoDataSource" database="mongodb://*.*.*.*/testdb" />
<document name="data">
<entity
name="products"
processor="MongoEntityProcessor"
query="{idStr,name,code,description,price,brand,size,color}"
collection="products"
datasource="mymongodb"
transformer="MongoMapperTransformer" >
<field column="idstr" name="idstr" mongoField="idStr"/>
<field column="name" name="name" mongoField="name"/>
<field column="code" name="code" mongoField="code"/>
<field column="description" name="description" mongoField="description"/>
<field column="price" name="price" mongoField="price"/>
<field column="brand" name="brand" mongoField="brand"/>
<field column="size" name="size" mongoField="size"/>
<field column="color" name="color" mongoField="color"/>
<entity
name="categories"
processor="MongoEntityProcessor"
query="{'idStr':'${categories.idstr}'}"
collection="categories"
datasource="mymongodb"
transformer="MongoMapperTransformer">
<field column="type" name="type" mongoField="type"/>
</entity>
</entity>
</document>
</dataConfig>
I am trying to join the field idStr of categories collection with the idStr of products collection(field name => idstr) and get the above fields ( name,description,... from products and type field from categories).
Any comments/solution on this exception would be really appreciated.Thanks!
Your SOLR field is declared as idstr but you are referencing it in the query attribute of dataConfig as idStr (camelcase difference).
I was able to resolve this ...
Following is the working configuration in the data-source-config file :
<entity
name="products"
query="select idStr,name,code,description,price,brand,size,color from products">
<field name="prodidStr" column="idStr" />
<field name="name" column="name" />
<field name="code" column="name" />
<field name="description" column="description" />
<field name="price" column="price" />
<field name="brand" column="brand" />
<field name="size" column="size" />
<field name="color" column="color" />
<entity
name="categories"
dataSource="mongod"
query="select idStr,ancestors from categories where idStr = '${products.idStr}'">
<field name="catidStr" column="idStr" />
<field name="ancestors" column="ancestors" />
</entity>
</entity>

How to make many2one field auto-complete in Odoo(formerly openerp)?

We have partner_id field in sale order form, I want to make that field auto-complete when user going to input the value, any suggestions will be welcome.
my code is :
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="air_odoo_sale_order_view" model="ir.ui.view">
<field name="name">air.odoo.sale.order.view</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<field name="partner_id" position="attributes">
<attribute name="group">base.group_manager,base.group_sale_salesman</attribute>
</field>
</field>
</record>
</data>
</openerp>

Activate a workflow transition from wizard in OpenERP 7.0

I've set up a wizard in OpenERP 7.0 that is updating fields correctly and all is working fine. But I would like to send a signal to the workflow from that wizard after user submits information to check if there is any transition to be taken.
My wizard code is the following:
from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.translate import _
class ref_generic_request(osv.osv_memory):
_name='ref.generic.request'
_columns = {
'reformulation_info': fields.text('Reformulation instructions', help='Instructions for the requestor justification the reformulation needs'),
}
def save_info(self, cr, uid, ids, context=None):
if 'active_id' in context:
info=self.browse(cr,uid,ids)[0].reformulation_info
self.pool.get('generic.request').write(cr,uid,context['active_id'],{'reformulation_info' : info, 'needs_reformulation': 1})
return {
'type': 'ir.actions.act_window_close',
}
ref_generic_request()
And in this particular case I would like to signal this function in my generic.request object:
def req_reformulate_request(self, cr, uid, ids, context=None):
req = self.browse(cr, uid, ids, context=context)
goto = req[0].state
if goto:
self.write(cr, uid, ids, {'goto': goto, 'state': 'req_reformulation', 'needs_reformulation': True} )
else:
self.write(cr, uid, ids, {'state': 'req_reformulation', 'needs_reformulation': True})
self.insert_trace(cr, uid, ids, context)
return True
How should I do that?
Do I have to call the function inside the def save_info()? (I've tried this call self.pool.get('generic.request').req_reformulate_request(cr, uid, context['active_id'], context) but it throws so many errors, that I quickly gave up this approach)
Do I have to return something like 'signal': 'generic.request.req_reformulate_request' ?
Since I didn't find any information on this, I'm completely lost here, so any help would be very appreciated!
Thanks!
Here is the workflow definition:
<?xml version="1.0"?>
<openerp>
<data>
<record model="workflow" id="wkf_request">
<field name="name">request.wkf</field>
<field name="osv">generic.request</field>
<field name="on_create">True</field>
</record>
<!-- actividades -->
<record model="workflow.activity" id="act_draft">
<field name="wkf_id" ref="wkf_request" />
<field name="flow_start">True</field>
<field name="name">request_draft</field>
<field name="kind">function</field>
<field name="action">request_draft()</field>
</record>
<record model="workflow.activity" id="act_submit">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_submitted</field>
<field name="kind">function</field>
<field name="action">submit_request()</field>
</record>
<record model="workflow.activity" id="act_confirm">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_confirmed</field>
<field name="kind">function</field>
<field name="action">confirm_request()</field>
</record>
<record model="workflow.activity" id="act_closed_nconf">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_closed_nconf</field>
<field name="action_id" ref="ir_actions_server_send_email_when_closed_nconf"/>
<field name="kind">function</field>
<field name="action">close_nconf_request()</field>
<field name="flow_stop">True</field>
</record>
<record model="workflow.activity" id="act_req_reformulate">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_reformulation</field>
<field name="kind">function</field>
<field name="action">req_reformulate_request()</field>
</record>
<record model="workflow.activity" id="act_treatment">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_treatment</field>
<field name="kind">function</field>
<field name="action">treat_request()</field>
</record>
<record model="workflow.activity" id="act_taken">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_take</field>
<field name="kind">function</field>
<field name="action">take_request()</field>
</record>
<record model="workflow.activity" id="act_given">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_give</field>
<field name="kind">function</field>
<field name="action">give_request()</field>
</record>
<record model="workflow.activity" id="act_closed">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_closed</field>
<field name="kind">function</field>
<field name="action">close_request()</field>
<field name="flow_stop">True</field>
</record>
<record model="workflow.activity" id="act_awaiting_auth">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_awaiting_authorization</field>
<field name="kind">function</field>
<field name="action">wait_auth_request()</field>
</record>
<record model="workflow.activity" id="act_closed_ref">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_closed_ref</field>
<field name="kind">function</field>
<field name="action">close_ref_request()</field>
<field name="flow_stop">True</field>
</record>
<record model="workflow.activity" id="act_awaiting_appr">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_awainting_approval</field>
<field name="kind">function</field>
<field name="action">wait_appr_request()</field>
</record>
<record model="workflow.activity" id="act_closed_disappr">
<field name="wkf_id" ref="wkf_request" />
<field name="name">request_closed_disappr</field>
<field name="kind">function</field>
<field name="action">close_disappr_request()</field>
<field name="flow_stop">True</field>
</record>
<!-- transições -->
<record model="workflow.transition" id="request_t1">
<field name="act_from" ref="act_draft" />
<field name="act_to" ref="act_submit" />
<field name="signal">submit_request</field>
</record>
<!--
<record model="workflow.transition" id="request_t101">
<field name="act_from" ref="act_draft" />
<field name="act_to" ref="act_confirm" />
<field name="signal">submit_request</field>
<field name="condition">check_responsible()</field>
</record>
-->
<record model="workflow.transition" id="request_t102">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_confirm" />
<field name="condition">check_responsible()</field>
</record>
<record model="workflow.transition" id="request_t2">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_req_reformulate" />
<field name="signal">req_reformulate_request</field>
</record>
<record model="workflow.transition" id="request_t3">
<field name="act_from" ref="act_req_reformulate" />
<field name="act_to" ref="act_submit" />
<field name="signal">submit_request</field>
</record>
<record model="workflow.transition" id="request_t1001">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_confirm" />
<field name="condition">ref_goto_confirmed()</field>
</record>
<record model="workflow.transition" id="request_t1002">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_treatment" />
<field name="condition">ref_goto_treatment()</field>
</record>
<record model="workflow.transition" id="request_t4">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_confirm" />
<field name="signal">confirm_request</field>
</record>
<record model="workflow.transition" id="request_t5">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_closed_nconf" />
<field name="signal">close_nconf_request</field>
</record>
<record model="workflow.transition" id="request_t6">
<field name="act_from" ref="act_confirm" />
<field name="act_to" ref="act_treatment" />
<field name="signal">treat_request</field>
</record>
<record model="workflow.transition" id="request_t7">
<field name="act_from" ref="act_treatment" />
<field name="act_to" ref="act_closed" />
<field name="signal">close_request</field>
</record>
<record model="workflow.transition" id="request_t7011">
<field name="act_from" ref="act_treatment" />
<field name="act_to" ref="act_taken" />
<field name="signal">take_request</field>
</record>
<record model="workflow.transition" id="request_t7012">
<field name="act_from" ref="act_taken" />
<field name="act_to" ref="act_treatment" />
</record>
<record model="workflow.transition" id="request_t7021">
<field name="act_from" ref="act_treatment" />
<field name="act_to" ref="act_given" />
<field name="signal">give_request</field>
</record>
<record model="workflow.transition" id="request_t7022">
<field name="act_from" ref="act_given" />
<field name="act_to" ref="act_treatment" />
</record>
<record model="workflow.transition" id="request_t8">
<field name="act_from" ref="act_treatment" />
<field name="act_to" ref="act_awaiting_auth" />
<field name="signal">wait_auth_request</field>
</record>
<record model="workflow.transition" id="request_t9">
<field name="act_from" ref="act_awaiting_auth" />
<field name="act_to" ref="act_closed_ref" />
<field name="signal">close_ref_request</field>
</record>
<record model="workflow.transition" id="request_t10">
<field name="act_from" ref="act_awaiting_auth" />
<field name="act_to" ref="act_treatment" />
<field name="signal">auth_send_processing</field>
</record>
<record model="workflow.transition" id="request_t11">
<field name="act_from" ref="act_treatment" />
<field name="act_to" ref="act_req_reformulate" />
<field name="signal">req_reformulate_request</field>
</record>
<record model="workflow.transition" id="request_t12">
<field name="act_from" ref="act_treatment" />
<field name="act_to" ref="act_awaiting_appr" />
<field name="signal">wait_appr_request</field>
</record>
<record model="workflow.transition" id="request_t13">
<field name="act_from" ref="act_awaiting_appr" />
<field name="act_to" ref="act_closed_disappr" />
<field name="signal">close_disappr_request</field>
</record>
<record model="workflow.transition" id="request_t14">
<field name="act_from" ref="act_awaiting_appr" />
<field name="act_to" ref="act_treatment" />
<field name="signal">appr_send_processing</field>
</record>
</data>
</openerp>
The transition I want to trigger in this particular case is the one with id="request_t2"
<record model="workflow.transition" id="request_t2">
<field name="act_from" ref="act_submit" />
<field name="act_to" ref="act_req_reformulate" />
<field name="signal">req_reformulate_request</field>
</record>
And here is a screenshot of the workflow, the highlighted transition is the one I want to trigger.
I finaly found the answer. I'll leave here the modified python code that made it!
from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.translate import _
import netsvc
class ref_generic_request(osv.osv_memory):
_name='ref.generic.request'
_columns = {
'reformulation_info': fields.text('Reformulation instructions', help='Instructions for the requestor justification the reformulation needs'),
}
def save_info(self, cr, uid, ids, context=None):
if 'active_id' in context:
info=self.browse(cr,uid,ids)[0].reformulation_info
self.pool.get('generic.request').write(cr,uid,context['active_id'],{'reformulation_info' : info, 'needs_reformulation': 1})
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid,'generic.request',context['active_id'],'req_reformulate_request',cr)
return {
'type': 'ir.actions.act_window_close',
}
ref_generic_request()
So, resuming, I had to add 3 lines to my code:
import netsvc
And, after saving my info, invoked the workflow with these two:
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid,'generic.request',context['active_id'],'req_reformulate_request',cr)
Hope this will help someone! :)
On odoo8 use signal_workflow method.
#api.multi
def confirm_multi_payslips(self):
for payslip in self:
payslip.signal_workflow('hr_verify_sheet')