Rules for a group in openerp 7 - rules

I have inherited project task module and created a group 'Inspector'.
I need to create a rule, when a inspector logged in, see tasks that assigned to him only. I created a rule is given below:
<record model="ir.rule" id="project_inspector_project_tasks_rule">
<field name="name">Inspector Project Tasks</field>
<field model="ir.model" name="model_id" ref="model_project_task"/>
<field name="domain_force">[('user_id','=','user.id')]</field>
</record>
but it doesn't work. Please help me.

In domain has following syntax:
[('field_name', 'operator', 'field_value')]
In your case, field_value will be integer. You given value as a string.
Try with this code:
<record model="ir.rule" id="project_inspector_project_tasks_rule">
<field name="name">Inspector Project Tasks</field>
<field name="model_id" ref="project.model_project_task"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
</record>

Related

Business Central - POST sales invoice line using REST API - setting multiple dimension values

We use Business Central cloud API to POST sales invoices from other system
After creating the the sales invoice we create sales invoice lines to it
by using
{BC Endpoint}/SalesInvoiceLine API call
but we are able to enter only two shortcut dimensions
eg.
"Shortcut_Dimension_1_Code": "{value_fordim1}",
"Shortcut_Dimension_2_Code": "{value_fordim2}
HOWEVER we need to set 4 dimensions for sales invoice line
We have tried to search MS API documentation for this situation but no luck
So far we haven't found a way to set all 4 dimension values to sales invoice line directly.
Current assumption is that we should somehow add new dimension set entry to BC
(or search suitable combination from Dimension Set Entry table)
and then somehow tie the sales invoice line to that Dimension Set Entry ID. However we do not know what API calls we could use for this.
Any guidance or help appriciated
In API v2.0 both entities salesInvoice and salesInvoiceLine contain a child object dimensionSetLines. If you run a request on the $metadata endpoint, you can find the definition in the API metadata.
<EntityType Name="dimensionSetLine">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.Guid" Nullable="false"/>
<Property Name="code" Type="Edm.String" Nullable="false" MaxLength="20"/>
<Property Name="parentId" Type="Edm.Guid"/>
<Property Name="parentType" Type="Microsoft.NAV.dimensionSetEntryBufferParentType"/>
<Property Name="displayName" Type="Edm.String" MaxLength="30"/>
<Property Name="valueId" Type="Edm.Guid"/>
<Property Name="valueCode" Type="Edm.String"/>
<Property Name="valueDisplayName" Type="Edm.String" MaxLength="50"/>
To view all dimensions on an invoice, send a GET request on
https://<Tenant URL>/api/v2.0/salesInvoices(<Invoice ID (GUID)>)?$expand=dimensionSetLines
To create an invoice with multiple dimension, include the dimensionSetLines object in the salesInvoice entity when sending the POST request.
{
"invoiceDate": "2024-01-22",
"postingDate": "2024-01-22",
"customerNumber": "10000",
"dimensionSetLines": [
{
"code": "SALESCAMPAIGN",
"valueCode": "SUMMER"
},
{
"code": "PROJECT",
"valueCode": "VW"
},
{
"code": "BUSINESSGROUP",
"valueCode": "INTERCOMPANY"
}
]
}
We were able to solve this by using:
POST {BC-endpoint}/SalesInvoiceLine call
and just by entering the additional shortcut dimensions to the body
{
.......
"ShortcutDimCode4": "{value_for_dim4}",
"ShortcutDimCode5": "{value_for_dim5}"
}

The table with name already exist

I'm trying to solve this issue
when doing
php bin/console doctrine:schema:update --dump-sql
I am getting
In SchemaException.php line 108:
The table with name 'chris_test_sonata.page__block' already exists.
Obviously, the table isn't existing in my database. To be sure it was not something cache related I even made the operation with a new database I just created, the result is the same.
When I search for page__block occurences in my project I only find this mapping
/**
* #ORM\Entity
* #ORM\Table(name="page__block")
* #ORM\HasLifecycleCallbacks
*/
class SonataPageBlock extends BaseBlock
So there should not be other mapping for this table.
I also have a block.orm.xml
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/easy-extends )
References :
xsd : https://github.com/doctrine/doctrine2/blob/master/doctrine-mapping.xsd
xml mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/xml-mapping/en
association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en
-->
<entity
name="App\Application\Sonata\PageBundle\Entity\Block"
table="page__block"
repository-class="Doctrine\ORM\EntityRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>
There is some other occurences but all in dev.log
And I also have this in a cache file from symfony dev/pools
<?php
namespace Symfony\Component\VarExporter\Internal;
return $getExpiry ? PHP_INT_MAX : Hydrator::hydrate(
$o = [
clone (($p = &Registry::$prototypes)['Doctrine\\ORM\\Mapping\\Entity'] ?? Registry::p('Doctrine\\ORM\\Mapping\\Entity')),
clone ($p['Doctrine\\ORM\\Mapping\\Table'] ?? Registry::p('Doctrine\\ORM\\Mapping\\Table')),
clone ($p['Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks'] ?? Registry::p('Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks')),
],
null,
[
'stdClass' => [
'name' => [
1 => 'page__block',
],
],
],
[
$o[0],
$o[1],
$o[2],
],
[]
);
I have no idea what is wrong with it and why the mapping is'nt working.
The problem is that you have Block entity with table page__block and you created a new entity SonataPageBlock with same table name. If you change table name of SonataPageBlock everything be fine, but it will be 2 different tables in database.
If you are looking way for extending base entity you can read about Table Inheritance.
For anyone who finds this on a search, receiving this error means that the table name already exists within an annotation.
#ORM\Table(name="page__block")
I had this problem with ManyToMany relationship. I was declaring the associative table twice ( one time in each entity )
In my case with Sylius there was an entity class that extends an entity from a plugin.
I did fix it by adding a class model in config/packages/_sylius.yaml :
sylius_taxonomy:
resources:
taxon:
classes:
model: App\Entity\Taxonomy\Taxon

Inject entity repository as dependency in Symfony

I have a Symfony project where I want to inject an entity repository into a service. The service definition is in XML format.
<service id="vendorname_shop.checkout_data_manager" class="Vendorname\ShopBundle\Checkout\CheckoutDataManager">
<argument type="service" id="security.token_storage" />
<argument type="service" id="session" />
<argument type="service" id="vendorname_shop.repository.pickup_point" />
<argument type="service" id="vendorname_shop.repository.order_payment_method" />
<argument type="service" id="vendorname_shop.repository.billing_address" />
</service>
I'd like to make vendorname_shop.repository.billing_address service to be a simple entity repository (not a custom class that I wrote, but the result of
EntityManager->getRepository(Vendorname\ShopBundle\Entity\BillingAddress::class)
method call), so I used the factory syntax in the xml, but I keep recieving error messages when Symfony tries to evaluate the argument:
<service id="vendorname_shop.repository.billing_address" class="Doctrine\ORM\EntityRepository">
<factory service="doctrine.orm.entity_manager" method="getRepository" />
<argument type="expression">Vendorname\ShopBundle\Entity\BillingAddress::class</argument>
</service>
The code above gives me Unexpected character "\" around position 11.
You can try something like this:
services:
my_service_name:
class: AppBundle\Controller\MyServiceName
arguments: ["#=service('doctrine.orm.entity_manager').getRepository('AppBundle:MyEntity')"]
Then you have build a service for your repository.
public function __construct(MyEntityRepository $repository) {
$this->repository = $repository;
}
But i think there are a lot more possibilities.
http://www.zuellich.de/blog/2016/03/symfony-3-inject-entity-repository-into-service-controller.html
here is another solution. I've replaced my answer with some of that solution it is a bit better.
As Cerad said, if I use a fully qualified name, the ::class is totally useless!
In addition changing the argument type to string solved the problem!
<argument type="string">Vendorname\ShopBundle\Entity\BillingAddresss</argument>

datanucleus - Attempting to illegally override the primary-key

I am using datanucleus JDO API for persisting objects.
my orm file looks like this:
<class name="MyClass" table="mytable">
<inheritance strategy="complete-table"/>
<field name="id" column="id" primary-key="true" value- strategy="AUTO_INCREMENT"/>
</class>
I have an inheritance hierarchy of
#PersistenceCapable
public class MyClass extends NonAbstractMyClassParent {
}
public class NonAbstractMyClassParent extends AbstractMyClassParent
{
}
public class AbstractMyClassParent
{
private Long id;
}
The id is defined in the MyClassAbstractParent.
MyClassParent does NOT have a corresponding table in the database.
When I try to persist the MyClass, I get the below error. I tried making the MyClassParent also abstract but still I get the same error.
Any insights please?
TIA
javax.jdo.JDOException: Metadata for member "com.xxx.MyClass.id" is attempting to illegally override the primary-key setting of its "root" metadata definition (annotations or ".jdo" XML file). You must specify primary-key information in the "root" metadata definition
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.initialiseMetaData(JDOPersistenceManagerFactory.java:772)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.(JDOPersistenceManagerFactory.java:564)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:308)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:217)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1975)
Move
<field name="id" column="id" primary-key="true" value- strategy="AUTO_INCREMENT"/>
to the class that defines that field, namely AbstractMyClassParent (whilst also marking it as persistence capable).

Organization level key value map operation in apigee

I'm trying to use a key/value map operation on apigee edge but I can't seem to get any variables. I've since figured out that I have created an organization level key/value but I still can't figure out how to get the values. The data I created was from the samples and looks as follows:
{
"entry": [
{
"name": "Development",
"value": "65.87.18.18"
},
{
"name": "Staging",
"value": "65.87.18.22"
}
],
"name": "ipAddresses"
}
I've configured my policy up like so
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Key-Value-Map-Operations-1" mapIdentifier="ipAddresses">
<DisplayName>Key Value Map Operations 1</DisplayName>
<FaultRules/>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<Get assignTo="myvar" index="1" >
<Key>
<Parameter ref="entry.Development"></Parameter>
</Key>
</Get>
<Scope>organization</Scope>
</KeyValueMapOperations>
But whenever I run a trace on this, myVar is always empty. I've tried various values for the Parameter ref such as
entry
Development
entry.Development
But nothing seems to work. Any suggestions? Do I need a basic auth header in there somewhere?
I've even tried doing this on an apiproxy scope and seeding the map at the same time, but even this doesn't return anything. And this is using the defaults from the policy!
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Key-Value-Map-Operations-2" mapIdentifier="newkey">
<DisplayName>Key Value Map Operations 2</DisplayName>
<FaultRules/>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<InitialEntries>
<Entry>
<Key>
<Parameter>k1</Parameter>
</Key>
<Value>v1</Value>
</Entry>
<Entry>
<Key>
<Parameter>k2</Parameter>
</Key>
<Value>v3</Value>
<Value>v4</Value>
</Entry>
</InitialEntries>
<Get assignTo="mynewvar" index="1">
<Key>
<Parameter ref="k1"></Parameter>
</Key>
</Get>
<Scope>apiproxy</Scope>
</KeyValueMapOperations>
I can't help but think I'm missing something really obvious, or I've totally misunderstood the concept of the maps
For anyone else who has this problem, the issue was I was using
<Parameter ref="k1"></Parameter>
To retrieve the value when in fact it should be
<Parameter>k1</Parameter>

Resources