I wanted to add another status ("advanced") to account.invoice's workflow, between "open" and "paid".
So I inherited the module with
class advance_invoice_workflow(osv.osv) :
_name = 'account.invoice'
_inherit = "account.invoice"
_columns = {
'state': fields.selection([
('draft','Draft'),
('proforma','Pro-forma'),
('proforma2','Pro-forma'),
('open','Open'),
('advanced','Advanced'),
('paid','Paid'),
('paid_advanced','Paid advanced'),
('cancel','Cancelled'),
],'Status', select=True, readonly=True, track_visibility='onchange',
help='* The \'Draft\' status is used when a user is encoding a new and unconfirmed Invoice. \
\n* The \'Pro-forma\' when invoice is in Pro-forma status,invoice does not have an invoice number. \
\n* The \'Open\' status is used when user create invoice,a invoice number is generated.Its in open status till user does not pay invoice. \
\n* The \'Paid\' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled. \
\n* The \'Cancelled\' status is used when user cancel invoice. \
'),
}
and declared the status in the XML file by making
<record id="act_advanced" model="workflow.activity">
<field name="wkf_id" ref="account.wkf" />
<field name="name">advanced</field>
<field name="kind">function</field>
<field name="action">set_advanced()</field>
</record>
So I have two transitions:
the first one from open to advanced,
<record id="t2" model="workflow.transition">
<field name="act_from" ref="account.act_open" />
<field name="act_to" ref="act_advanced" />
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_advanced()</field>
<field name="signal">button_confirm_advance</field>
</record>
the second one from advanced to paid
<record id="t1" model="workflow.transition">
<field name="act_from" ref="act_advanced"/>
<field name="act_to" ref="account.act_paid"/>
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_paid()</field>
</record>
From an external module, that does not inherit from account.invoice, but that refers to it, I want to send the signal to the workflow to move from "act_open" to "act_advanced".
So I added a button with name="button_confirm_advance" that binds this action:
def button_confirm_advance(self,cr,uid,ids,context=None):
context = context or {}
for invoice in self.browse(cr,uid,ids,context=context):
wf_service = netsvc.LocalService("workflow")
self.write(cr, uid, [invoice.id],{})
wf_service.trg_validate(uid,'account.invoice',invoice.id,'button_confirm_advance',cr)
return {'type': 'ir.actions.act_window_close'}
All variables are correct, but the trg_validate returns False.
What am I wrong?
Thanks,
Patrizio
I solved delegating the flowchart management to another class that inherits from account.invoice
class advance_invoice_account_ui(osv.osv) :
_name = 'account.invoice'
_inherit = "account.invoice"
Related
I have created a Fiori Elements List Report and set the table type to TreeTable. The table is displayed as a TreeTable but every entity is displayed as a root entity in the table and the following error is in the log: "Neither navigation paths parameters, nor (complete/valid) tree hierarchy annotations where provided to the TreeBinding.".
The OData service is based on the following projection view:
#Metadata.allowExtensions: true
#ObjectModel.representativeKey: 'Element'
#ObjectModel.dataCategory: #HIERARCHY
#Hierarchy.parentChild: [
{ recurse.child: ['Element'],
recurse.parent: ['ParentElement'],
recurseBy: '_ParentElement',
multipleParents: true,
siblingsOrder: [{by: 'Element', direction: #DESC}],
orphanedNode.handling: #ROOT_NODES
}
]
define root view entity ZC_Element
as projection on ZI_Element
{
#ObjectModel.foreignKey.association: '_Element'
key Element,
ParentElement,
ChildNode,
ParentNode,
HierarchyLevel,
HierarchyTreeSize,
HierarchyRank,
HierarchyParentRank,
HierarchyIsOrphan,
HierarchyIsCycle,
HierarchyDrillState,
CreatedBy,
CreatedAt,
LastChangedBy,
LastChangedAt,
_Element,
_ParentElement
}
The hierarchy, which is at the basis of the views, is as followed:
define hierarchy ZHI_ElementHierarchy
as parent child hierarchy(
source ZHI_ElementRelation
child to parent association _ParentElement
start where
ParentElement is initial
siblings order by
Element
multiple parents allowed
orphans root
)
{
#ObjectModel.foreignKey.association: '_VirtualDirectory'
key Element,
_Element,
ParentElement,
_ParentElement,
$node.parent_id as ParentNode,
$node.node_id as ChildNode,
$node.hierarchy_is_orphan as HierarchyIsOrphan,
$node.hierarchy_level as HierarchyLevel,
$node.hierarchy_rank as HierarchyRank,
$node.hierarchy_parent_rank as HierarchyParentRank,
$node.hierarchy_tree_size as HierarchyTreeSize,
$node.hierarchy_is_cycle as HierarchyIsCycle,
CreatedBy,
CreatedAt,
LastChangedBy,
LastChangedAt
}
The metadata file of the OData service does not contain any hierarchy annotations. I have also attempted to add the following annotations manually to the annotations.xml file but this does not have any effect either:
<Annotations Target="cds_zsd_elements.ElementType">
<Annotation Term="UI.LineItem">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="Element"/>
<PropertyValue Property="sap:hierarchy-node-for" Path="Element"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="ParentElement"/>
<PropertyValue Property="sap:hierarchy-parent-node-for" Path="Element"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="HierarchyLevel"/>
<PropertyValue Property="sap:hierarchy-level-for" Path="Element"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="HierarchyDrillState"/>
<PropertyValue Property="sap:hierarchy-drill-state-for" Path="Element"/>
</Record>
</Collection>
</Annotation>
</Annotations>
I have used the projection view in an ABAP program with ALV TreeTable as well and the output is displayed correctly, so the hierarchy and data seems to be correct. What can I do to get the hierarchy annotations correct?
Im trying to add an email template to my custom module, When I add the email template like below I get an error.
odoo.tools.convert.ParseError: "insert or update on table "mail_template" violates foreign key constraint "mail_template_model_id_fkey"
The only way I can get the template installed to odoo is by removing the model_id field.
Ways Ive tried model_id: it_onboarding.it_onboarding ,it_onboarding.model_it_onboarding, model_it_onboarding, it_onboarding. All of those variations on the model name give External ID errors except it_onboarding.it_onboarding which give the foreign key constraint error.
Module name: it_onboarding.it_onboarding
Filename: data/it_request_approval_email.xml
Email Template:
<record id="it_request_email_template" model="mail.template">
<field name="name">New IT Request ${object.reference}</field>
<field name="model_id" ref="it_onboarding.it_onboarding"/>
<field name="subject">${object.reference} needs approval</field>
<field name="email_from">dummy#mail.com</field>
<field name="email_to">dummy#mail.com</field>
<field name="auto_delete" eval="False"/>
<field name="user_signature" eval="False"/>
<field name="body_html" type="html">
<div>
${object.reference} has been received and needs approval
</div>
</field>
Grateful for any ideas
File Structure
-it_onboarding
--controllers
--data
--it_request_approval_email.xml
--sequence.xml
--models
--reports
--security
--static
--views
--__init__.py
--__manifest__.py
Manifest
"data": [
'security/ir.model.access.csv',
'security/security.xml',
'data/sequence.xml',
'views/views.xml',
'views/templates.xml',
'views/it_user_view.xml',
'reports/it_user_report.xml',
'reports/it_request_report.xml',
'reports/approval_email_report.xml',
'data/it_request_approval_email.xml',
],
Try with this variation and if possible please provide a snip or link of your folder structure:
<field name="model_id" ref="folder_name.model_class_name"/>
Cheers!
I found my issue. I was formatting the model_id incorrectly.
Model name: it_onboarding.it_onboarding
model_id: model_it_onboarding_it_onboarding
I have a smartfield that has a value-list annotation.
I would like it to behave such that text input is disabled for the field so the user is forced to open the value help when he clicks on the field, and select from a valid list - much like the valueHelpOnly property of sap.m.Input. I was looking for a similar property for smartfield but there isn't seem to be one?
If there's no standard property for this, what's the best way to validate input vs valid value help values for smartfields?
Thanks in advance.
You need to do the following steps. Assume you defined the SmartField like this:
<smartField:SmartField value="{XXX}" textInEditModeSource="ValueList" innerControlsCreated="onControlCreated">
<smartField:configuration>
<smartField:Configuration preventInitialDataFetchInValueHelpDialog="false" displayBehaviour="idAndDescription"/>
</smartField:configuration>
</smartField:SmartField>
Of course you have defined the needed annotation that shows the value list itesm. Something like this:
<Annotations Target="Metadata.YourEntityName/XXX">
<Annotation Term="Common.Text" Path="Planttxt">
<Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextLast"/>
</Annotation>
<Annotation Term="Common.ValueListWithFixedValues" Bool="false"/>
<Annotation Term="Common.ValueList">
<Record>
<PropertyValue Property="CollectionPath" String="XxxSet"/>
<PropertyValue Property="Parameters">
<Collection>
<Record Type="Common.ValueListParameterInOut">
<PropertyValue Property="LocalDataProperty" PropertyPath="XXX"/>
<PropertyValue Property="ValueListProperty" String="Id"/>
</Record>
<Record Type="Common.ValueListParameterDisplayOnly">
<PropertyValue Property="ValueListProperty" String="Name"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
We defined a innerControlsCreated="onControlCreated" handler, we need to provide the code for that in related controller:
/**
* event fired by innerControlsCreated of SmartField
* #param {sap.ui.base.Event} oEvent pattern match event
*/
onControlCreated: function (oEvent) {
if (oEvent.getParameters()[0] instanceof sap.m.Input && oEvent.getParameters()[0].getShowValueHelp()) {
// set ValueHelpOnly for Inputs with ValueHelp
oEvent.getParameters()[0].setValueHelpOnly(true);
}
},
I have a work around, if any one has a better solution then kindly suggest me
Add a class to you SmartField and using the class get the ID and add disabled attribute to the SmartField input tag
var sSmrtFldId = "#" + jQuery(".CustomSmrtFldClass").attr("id") + ".sapMInputBaseInner";
jQuery(sSmrtFldId).attr("disabled ", true);
You have to use the Event innerControlsCreated of SmartField, then check if is a Input and call the method setValueHelpOnly(true)
onInnerControlsCreated: function (oEvent){
oEvent.getParameters()[0].setValueHelpOnly(true);
}
Note: This code is a sample, you need to check if is a Input and avoid hard code the index access on the array of parameters.
I'm trying to extend the modx modresource object, but keep getting errors & I can't seem to figure out why. It is related to the schema (I think) but everything looks correct.
Schema:
<?xml version="1.0" encoding="UTF-8"?>
<model package="extresource" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="modx_" version="1.0.0">
<object class="extResource" extends="modResource">
<composite alias="ResourceData" class="ResourceData" local="id" foreign="internalKey" cardinality="one" owner="local"/>
</object>
<object class="ResourceData" table="resource_data" extends="xPDOSimpleObject">
<field key="internalKey" dbtype="int" precision="11" phptype="integer" null="false" attributes="unsigned"/>
<field key="views" dbtype="int" precision="11" phptype="integer" null="true" />
<field key="starred" dbtype="int" precision="10" phptype="integer" null="false" />
<index alias="internalKey" name="internalKey" primary="false" unique="true" type="BTREE" >
<column key="internalKey" length="" collation="A" null="false" />
</index>
<aggregate alias="Resource" class="modResource" local="internalKey" foreign="id" cardinality="one" owner="foreign"/>
</object>
</model>
I'm testing it using:
$resource = $modx->getObject('modResource', 11112);
echo $resource->get('pagetitle'); //test I have the resource
$data = $resource->getOne('ResourceData');
The errors I get are:
Could not getOne: foreign key definition for alias ResourceData not
found. No foreign key definition for parentClass: modDocument using
relation alias: ResourceData
The table exists & has data, the package is registered in the modx extension packages. I've been over the schema many times & it looks right.
What is causing these errors?
You have to use the right object class in $modx->getObject. Otherwise you will get a modResource object, that does not know the extended object data and relationship.
$resource = $modx->getObject('extResource', 11112);
Does the resource you are loading have its class_key field set to extResource? That's needed for it to load the right resource object class.
I'm using fusion charts' funnel mode to display some sums which may or may not be 0, grouped into different cathegories. I'm also displaying the number of terms that goes into each sum (for example: $1000, 3 accounts). I want the funnel to display a slice even if its value is 0 and have it displayed like $0, x accounts to give the user information on how many accounts there are in every cathegory even if the final sum is 0.
Xml for the fusioncharts object:
$strXML = "
<chart showhovercap='1' showNames='1' showValues='1' numberSuffix=' lei' decimalPrecision='0' decimalSeparator=',' thousandSeparator='.' formatNumber='1' isSliced='1' slicingDistance='5' bgColor='f5f5f5'>
<set link='".$url1."' name='Negociere' value='".$negociere."' color='FD0006' hoverText='".$nr_negociere.$text_negociere."' />
<set link='".$url2."' name='Ofertare' value='".$oferta."' color='FF4100' hoverText='".$nr_oferta.$text_oferta."' />
<set link='".$url3."' name='Analiza' value='".$analiza."' color='FF8900' hoverText='".$nr_analiza.$text_analiza."' />
<set link='".$url4."' name='Abordare' value='".$abordare."' color='086FA1' hoverText='".$nr_abordare.$text_abordare."' />
<set link='".$url5."' name='Prospectare' value='".$prospectare."' color='00B25C' hoverText='".$nr_prospectare.$text_prospectare."' />
</chart>
";
Could you please try by setting "streamlinedData" attribute to "0" in the element of your XML data?
Ref. Code:
<chart showhovercap='1' showNames='1' showValues='1' numberSuffix='$' decimalPrecision='0' decimalSeparator=',' thousandSeparator='.' formatNumber='1' isSliced='1' slicingDistance='5' bgColor='f5f5f5' streamlinedData='0'>
<set label="Negociere,3 accounts" value="0"/>
<set label="Ofertare, 5 accounts" value="0"/>
<set label="Analiza, 2 accounts" value="1"/>
<set label="Abordare, 1 accounts" value="0"/>
<set label="Prospectare, 2 accounts" value="0"/>
</chart>