Browse Source

Merge pull request #896 from akretion/10-date_range_improve

[10.0] date_range: improve 'name' for generator wizard
pull/897/head
Stéphane Bidoul (ACSONE) 7 years ago
committed by GitHub
parent
commit
8601033e22
  1. 2
      date_range/__manifest__.py
  2. 28
      date_range/security/date_range_security.xml
  3. 4
      date_range/wizard/date_range_generator.py

2
date_range/__manifest__.py

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

4
date_range/wizard/date_range_generator.py

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

Loading…
Cancel
Save