Filter on a field

Hello , i have an question on filter.

I have a company field where i can select my company I want. Now i would like to know how to filter my projects according to their belonging to the company.

A part of my code:

<panel name="actionPanelCopy" sidebar="true" showIf="statusSelect == 3">
				<field name="$projectCopy" title="Project" type="many-to-one" onChange="action-hr-timesheet-record-empty-product" onSelect="action-hr-timesheet-attrs-domain-projectCopy" target="com.axelor.apps.project.db.Project" domain="self.imputable=true and self. AND :company project of self.companySet" form-view="project-form" grid-view="project-grid"/>
				<button name="copyBtn" onClick="action-timesheet-methode-copy" title="Timesheet copy"/>
			</panel>

<action-record name="action-hr-timesheet-record-empty-product" model="com.axelor.apps.hr.db.Timesheet">
	<field name="$product" expr="eval:null" if="!$project?.productSet?.contains(product)"/>
</action-record>

<action-attrs name="action-hr-timesheet-attrs-domain-projectCopy">
	<attribute name="domain" for="$projectCopy" expr="eval: &quot; ${user?.id} MEMBER OF self.membersUserSet AND self.assignedTo.id = ${user?.id} &quot;"/>
</action-attrs>

Thank’s for your help.

there are few missing words in domain query, try the following
self.company.id in ( user.companySet.id.plus(0) )

Like this ?

domain="self.imputable=true and self.company.id in ( user.companySet.id.plus(0) )"

How does the filter know that my company has been selected in my other field?

it’s not user. it’s

__user__

it’s built in variable

After lot of tests I can’t filter. All projects of all companies are displayed…

no worries take time off I will share tested solution

self represent the project model, __user__ represent the logged in user, so query filtering those project whose company is in company set of logged in user

I tried a lot of things, even the simplest and yet nothing works.

If i write this in my domain :

domain="self.company = 0"

My field must return only my projects with company ID is 0 ?

Finally, i dropped the filter…

I modify the expr with

<action-attrs name="action-hr-timesheet-attrs-domain-projectCopy">
<attribute name="domain" for="$projectCopy" expr="eval: &quot; self.company.id = ${company?.id} &quot;"/>

it works !

2 « J'aime »

so finally it worked

Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.