forked from Yaltik/golem
Add age and area_id filter for contacts
This commit is contained in:
parent
a8807a9798
commit
34a697d5dc
@ -19,6 +19,8 @@
|
|||||||
""" GOLEM Members """
|
""" GOLEM Members """
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import date, timedelta
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -85,6 +87,15 @@ class ResPartner(models.Model):
|
|||||||
""" GOLEM Member partner adaptations """
|
""" GOLEM Member partner adaptations """
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
age = fields.Integer(compute='_compute_age', store=True)
|
||||||
|
|
||||||
|
@api.depends('birthdate_date')
|
||||||
|
def _compute_age(self):
|
||||||
|
for contact in self:
|
||||||
|
if contact.birthdate_date:
|
||||||
|
age = relativedelta(date.today(), fields.Date.from_string(contact.birthdate_date))
|
||||||
|
contact.age = age.years
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_default_nationality_id(self):
|
def _get_default_nationality_id(self):
|
||||||
return self.env.ref('base.main_company').country_id
|
return self.env.ref('base.main_company').country_id
|
||||||
|
@ -48,6 +48,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
position="after">
|
position="after">
|
||||||
<field name="area_id" placeholder="Area, quarter..."
|
<field name="area_id" placeholder="Area, quarter..."
|
||||||
options="{'no_create': true}" />
|
options="{'no_create': true}" />
|
||||||
|
<field name="age"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@ -90,6 +91,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="name" position="after">
|
<field name="name" position="after">
|
||||||
<field name="member_number" />
|
<field name="member_number" />
|
||||||
|
<field name="area_id"/>
|
||||||
|
<field name="age"/>
|
||||||
</field>
|
</field>
|
||||||
<filter name="filter_my_partners" position="before">
|
<filter name="filter_my_partners" position="before">
|
||||||
<filter name="is_subscriber" string="Is Subscriber"
|
<filter name="is_subscriber" string="Is Subscriber"
|
||||||
@ -103,6 +106,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<separator />
|
<separator />
|
||||||
<filter name="is_service_user" string="Is Service User"
|
<filter name="is_service_user" string="Is Service User"
|
||||||
domain="[('member_id', '!=', False)]" />
|
domain="[('member_id', '!=', False)]" />
|
||||||
|
<filter name="by_are_id" string="By Area"
|
||||||
|
context="{'group_by': area_id}"/>
|
||||||
<separator />
|
<separator />
|
||||||
</filter>
|
</filter>
|
||||||
</field>
|
</field>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user