Skip to content

Commit

Permalink
[FIX] co-residency management into the printing process label
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Nemry (ACSONE) committed Nov 17, 2015
1 parent 1f9d18a commit 3a45bba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions mozaik_address/reports/report_postal_coordinate_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, cr, uid, name, context):
cr, uid, name, context=context)
self.localcontext.update({
'modulo': self._modulo,
'co': context.get('groupby_co_residency'),
})

def _modulo(self, number, modulo):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
</t>
<!-- Put more margin-left for the second and third sticker so they will be centered -->
<div class="col-xs-3 card" t-att-style="modulo(o_index, 3) != 0 and 'margin-left:'+ str(10+((1-modulo(modulo(o_index, 3),2))*2))+'mm;' or ''">
<t t-if="not o.co_residency_id">
<t t-if="not o.co_residency_id or not co">
<span t-esc="o.partner_id.printable_name"/><br/>
</t>
<t t-if="o.co_residency_id and o.co_residency_id.line">
<t t-if="o.co_residency_id and o.co_residency_id.line and co">
<span t-esc="o.co_residency_id.line"/><br/>
</t>
<t t-if="o.co_residency_id and o.co_residency_id.line2">
<t t-if="o.co_residency_id and o.co_residency_id.line2 and co">
<span t-esc="o.co_residency_id.line2"/><br/>
</t>
<t t-if="o.address_id.street2">
Expand All @@ -98,6 +98,7 @@
<div class="pageTop" t-if="o_first or modulo(o_index, 33) == 0"/>

<t t-call="mozaik_address.postal_coordinate_label_report_card">
<t t-set="co" t-value="co"/>
<t t-set="o" t-value="o"/>
<t t-set="o_index" t-value="o_index"/>
</t>
Expand Down
17 changes: 15 additions & 2 deletions mozaik_communication/wizard/distribution_list_mass_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ def mass_function(self, cr, uid, ids, context=None):

if wizard.sort_by:
context['sort_by'] = wizard.sort_by
if wizard.groupby_coresidency:
context['alternative_group_by'] = 'co_residency_id'

csv_model = wizard.trg_model

Expand Down Expand Up @@ -295,9 +293,24 @@ def mass_function(self, cr, uid, ids, context=None):
self.post_processing(
cr, uid, wizard, active_ids, context=context)
ctx = context.copy()
if wizard.groupby_coresidency:
to_print_ids = []
co_res_ids = []
for postal in self.pool['postal.coordinate'].browse(
cr, uid, active_ids, context=context):
if postal.co_residency_id:
if postal.co_residency_id.id not in\
co_res_ids:
co_res_ids.append(
postal.co_residency_id.id)
to_print_ids.append(postal.id)
else:
to_print_ids.append(postal.id)
active_ids = to_print_ids
ctx.update({
'active_model': 'postal.coordinate',
'active_ids': active_ids,
'groupby_co_residency': wizard.groupby_coresidency,
})
report = self.pool['report'].get_pdf(
cr, uid, active_ids,
Expand Down

0 comments on commit 3a45bba

Please sign in to comment.