Browse Source

date_range: improve 'name' for generator wizard

ir.rule should be active by default
pull/896/head
Alexis de Lattre 7 years ago
parent
commit
3f9aa57999
  1. 2
      date_range/__manifest__.py
  2. 28
      date_range/security/date_range_security.xml
  3. 5
      date_range/wizard/date_range_generator.py

2
date_range/__manifest__.py

@ -4,7 +4,7 @@
{
"name": "Date Range",
"summary": "Manage all kind of date range",
"version": "10.0.1.0.0",
"version": "10.0.1.0.1",
"category": "Uncategorized",
"website": "https://odoo-community.org/",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",

28
date_range/security/date_range_security.xml

@ -1,19 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<record id="date_range_type_comp_rule" model="ir.rule">
<field name="name">Date Range Type multi-company</field>
<field name="model_id" ref="model_date_range_type"/>
<field eval="True" name="global"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field eval="False" name="active"/>
</record>
<record id="date_range_comp_rule" model="ir.rule">
<field name="name">Date Range multi-company</field>
<field name="model_id" ref="model_date_range"/>
<field eval="True" name="global"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
<field eval="False" name="active"/>
</record>
</data>
<odoo noupdate="1">
<record id="date_range_type_comp_rule" model="ir.rule">
<field name="name">Date Range Type multi-company</field>
<field name="model_id" ref="model_date_range_type"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
</record>
<record id="date_range_comp_rule" model="ir.rule">
<field name="name">Date Range multi-company</field>
<field name="model_id" ref="model_date_range"/>
<field name="domain_force"> ['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
</record>
</odoo>

5
date_range/wizard/date_range_generator.py

@ -43,6 +43,7 @@ class DateRangeGenerator(models.TransientModel):
count=self.count+1)
vals = list(vals)
date_ranges = []
month_digits = len(unicode(self.count))
for idx, dt_start in enumerate(vals[:-1]):
date_start = fields.Date.to_string(dt_start.date())
# always remove 1 day for the date_end since range limits are
@ -50,7 +51,9 @@ class DateRangeGenerator(models.TransientModel):
dt_end = vals[idx+1].date() - relativedelta(days=1)
date_end = fields.Date.to_string(dt_end)
date_ranges.append({
'name': '%s-%d' % (self.name_prefix, idx + 1),
'name': '%s-%s' % (
self.name_prefix,
unicode(idx + 1).zfill(month_digits)),
'date_start': date_start,
'date_end': date_end,
'type_id': self.type_id.id,

Loading…
Cancel
Save