I have two products. For example A and B. In A product i need to enable to one validation which is present in AValidator.xtend file and B product is depends on A so when i run B product that check needs to be disable the warning.
AValidator.xtend:
#Check
def validateElement(Element e)
{
warning('''Element «e.name» missing in files.''', e, package.Literals.NAMED__NAME)
}
The same check should not be work for BProduct.
Is there any override function can do for these?
Many thanks in advance.
There are two ways to solve this:
You can add a system property (probably a boolean flag) which enables this feature. In the ini file of A, you enable the option. In B, you omit it.
You can split the plugin into a library and then two plugins which you use in the products.
Splitting the plugin works like this:
You need to create a new plugin and copy all the shared code into it. It can also contain the code from the validation which is the same for both products. Give the validation code the name SharedValidator
In this plugin, you need to rename DslRuntimeModule (Dsl is the name of your grammer, it extends AbstractDslRuntimeModule which contains the binding for the validation). Rename it to SharedDslRuntimeModule.
Then you create a plugin for product A. It contains the specific validation. This class needs to extend SharedValidator.
You also need to create a binding which extends SharedDslRuntimeModule and so you can bind the new validator class.
That's the rough outline. You will have to copy/change several other files (like the DslStandaloneSetup and the plugin.xml), too, but those changes should become obvious when you fix the compile errors.
... Maybe a flag is more simple.
Solution for this problem is Creating extension point.
I have created one extension point in AProduct validator plugin with the name of interface IProdcutEnabled with one method.
And Added that extension point in BProduct validator plugin.
Then AProduct validator class,Validation i checked whether extension point is used by any product or not. If it's used don't show warning.
Related
I am attempting to build a little modification in our code to allow easier A/B testing.
I'd like to know if I can somehow
have my regular code under the /templates directory
have any a/b code under /templates/_abtests/, but also follow the same hierarchy as the regular code. for example... an ab test can overwrite a file like '/templates/foo.tpl', and use instead '/templates/_abtests/testfoo/foo.tpl'
I tried changing the template directory when in a test. Right before calling the display method, I would check if a user is in a test, and if so, set up the template_dir accordingly. I'd assign an array with the 'ab' directory first, then the default. I am using Smarty2.
the problem with this is that it caches the first instance, and uses that as the template for the baseline and ab test case. ie: i have a parameter to force me into a test bucket, but the template is the same.
thoughts on how to achieve this? goal is to not have to add a bunch of template hooks (if/else) in the templates. and achieve this by simple template/file includes.
I believe that the solution to my problem could be to put templates into folders. ie: /templates/base/, /templates/test_foo/, etc.". then in my template_dir setting, set the array up based on what test we are in.
I had tried this with mobile/desktop before, and forgot about this solution.
I can extend the smarty_template class and override the display method to change the template_dir. adding the test directory first.
I am trying to build a custom module based on the 'basic' template, with extra fields without using the module builder.
I have looked trough the SugarCRM 6.5 documentation, bought the book SuiteCRM for Developers and looked trough the sources of existing modules, but I still can not figure out how to put a working module together.
Does a minimal module template exists anywhere? What I am looking for is a fully working module with one extra field, which can be deployed on a SuiteCRM instance. I can take it from there.
There's no minimal module template that I know of, you may want to consider creating a test module through module builder and exporting that to see what the parts are.
Usually though modules have the following files. Example uses the module ABC_Sport.
custom/Extension/application/Ext/Include/ABC_Sport.php
This adds the module to the module list and adds the beans. I.e.
$beanList['ABC_Sport'] = 'ABC_Sport';
$beanFiles['ABC_Sport'] = 'modules/ABC_Sport/ABC_Sport.php';
$moduleList[] = 'ABC_Sport';
custom/Extension/application/Ext/Include/en_us.ABC_Sport.php
(Note you may want to add files for different languages).
Next up you'll need to create the bean file in
modules/ABC_Sport/ABC_Sport.php
and the vardefs in
modules/ABC_Sport/vardefs.php
I'm not totally sure if the metadata files are required or not but you'll also likely want to add the editviewdefs,detailviewdefs and listviewdefs.
Is there a simple way of associating a new custom field (in the customer record or in an order items) in OpenERP (oodo) with an external link (ie Description or an iframe) so that it can link to a different system?
Is there a simple way of initializing this link with a (new) GUID, when the record is created?
Is there a simple way injecting client side JavaScript into standard OpenERP pages?
Do I need to create a new module for this?
For OpenERP 7.0+
You can add an additional field of type text/char for the link to any object like the sale.order/purchase.order/any other object. This is both possible per module or webclient (if you have technical rights).
The simplest way to create a GUID whenever a record is created is to extend that record and override the constructor:
class extended_sale_order(osv.osv):
_name = 'sale.order' # override current sale.order by replacing it (same name)
_inherit = 'sale.order' # inherit from "original" sale.order
_columns = {
'GUID': field.text('GUID') # add GUID textfield
}
def create(self, cr, uid, vals, context=None):
'''
On sale.order construction create a GUID and replace the GUID field in
sale.order with the generated value.
'''
guid = generate_guid() # implement this or use oerp sequences
vals['GUID'] = guid
result = super(extended_sale_order,self).create(cr,uid,vals,context)
return result
Yes, you can add script/html directly into the views like described on OpenERP Bay Blog (I can't add more than 2 links.. spam protection probably, you can easily find the block with most search engines). The modifications can be done either with the web client and technical rights in the UI section or using a module which modifies the view - or by using the widget or another extension point for view related modifications which can use JS.
The crucial part is where to put the GUID creation on record creation logic. If you can do that in JS - for example by creating a new GUID and put it in the field whenever a new record is created with the form - and you know the objects are always created per web-client form it is okay. For a hack.
Writing a module and putting the logic into the Business-object is the clean solution for that. The development documentation for OERP modules is sufficient for this and there are good Tutorials out in the net for small problems like adding just an additional Field.
An OpenERP Module Programmer would probably just
create a Module
inherit the Model/Object which should be modified
add a field which holds the guid/link
optionally create a calculated field which builds the link from the guid field so you only need to save the guid or which creates arbitrary html which should inserted into the view
add some logic to the constructor to create and save the guid
inherit the views where the link should be placed
add the fields/content which should be shown f.e. using the xpath expression to place your new viewpart/field/content behind some other field
install and test it
restart the server whenever python code is changed
update the the module whenever xml is changed
Or short, yes these modifications are simple if you have sufficient knowledge of the technical parts of OpenERP and yes you should put that in a module to keep it clean.
I have a big ZF2 project using a lot of modules.
We need to find a way to automatically PREPEND an Optional custom route to every existing route in all modules, using code from only One module.
And it needs to work with the Url view helper.
In every module I have the default route which is basically :
/ModuleName[/:controller[/:action]]
But my new module (Company) needs to add a Company context to every route like so :
[/company/:company_id] /ModuleName[/:controller[/:action]]
As you may have understood, the /company/id part is Optional, and I need a default company_id.
I do not want to add this route in every module's config file.
I tried adding a route in the Company module's config file, but I quickly understood that we cannot define the MODULE parameter inside the route definition, since Zend2 uses namespaces instead.
Also, we will need to do the same thing for langs.
At the end, we will need something like this :
[/:lang][/company/:company_id]/ModuleName[/:controller[/:action]]
Without changing the current config files in any other existing module.
Anyone has The solution for this ?
thank you !
I have solved my problem, and will share it here if anyone needs it.
I will only explain the big idea without posting any line of code since it strongly depends on the way you built your project, and also, it is better to implement it your own way to understand it better, cause if you copy-paste it without trying to understand it WILL break your whole project.
That said, if you cannot understand this explanation, you cannot implement this anyways.
First of all, I have a BaseModule that every module class extends from, and this BaseModule implements the getConfig() method itself automatically and it is final so no module can override it.
If your project is not built like that it will NOT work and you can stop right here.
In this BaseModule I have a STATIC method called prependRouteSegment(), which basically adds key=>array to a PRIVATE STATIC array variable.
In my case, the key is the route and the array is the default params for this route.
Then, in the getConfig() method, after fetching the config file and before returning it as the config array, I can edit anything I want.
So basically I edit all the existing 'Segment' routes and concatenate my routes from the static variable and the original one, then I add my default params.
But there is one more thing that is very important, you need to actually set the custom routes from each Module BEFORE zend executes every module's getConfig() method.
To do so, first create a STATIC method initCustomRouting() that you can override in any module, then, say my first loaded module is Application, simply parse the list of modules in the __construct() method of your Application module and call this initCustomRouting() statically on each module.
Then, if a certain module needs to prepend a custom route to any existing route, you simply implement in this module the initCustomRouting() method and inside of it you call the prependRouteSegment() static method with your custom route and default params.
That's it !
Dont forget that you cannot use params in a Literal route, and you may not want to prepend something on a hostname route, so in my case I only add the routes to every 'Segment' routes, I simply compare the type when I loop through.
Hope this will help someone !
I have made a Doxygen documentation, which itself references another documentation using the tag-file mechanism. But inside its mainpage I now would like to link to the mainpage of the external documentation. Of course, I can always specify the file directly:
... uses [OtherDoc](../../../OtherProject/doc/html/index.html) for ...
even more so since the projects are located relative to each other. But nevertheless I would like Doxygen to automate this process, since it needs to know the location of the external documentation, anyway.
So is there a way to somehow symbolically reference the external documentation's mainpage, something along the lines of:
[OtherDoc](\ref OtherProject::mainpage)
or
[OtherDoc](#OtherProject::mainpage)
There is a trick to do this. Say you have projects A and B, then in the main page of project A you could put an #anchor command like so:
/** #mainpage
* #anchor project_a
*/
And in the documentation of project b you can then simply use
[OtherDoc](\ref project_a)
Note that anchors have to be globally unique, so you need to carefully choose them!