@@ -170,7 +170,7 @@ record['state'] = 'cancel'
170170]]> </field >
171171 <field name =" model_id" ref =" sale.model_sale_order" />
172172 <field name =" state" >code</field >
173- <field name =" name" >Industry : Split SO per Owner</field >
173+ <field name =" name" >Condominium : Split SO per Owner</field >
174174 </record >
175175 <record id =" action_server_set_usage_meter_reading" model =" ir.actions.server" >
176176 <field name =" code" ><![CDATA[ mrs = env['x_meter_reading'].search([('id', 'in', record.x_studio_property.x_studio_meter_reading_ids.ids), ('x_meter_id', '=', record.x_meter_id.id)], order='x_date')
@@ -182,7 +182,7 @@ for mr in mrs:
182182 ]]> </field >
183183 <field name =" model_id" ref =" model_meter_reading" />
184184 <field name =" state" >code</field >
185- <field name =" name" >Industry : Compute Meter Reading Consumption</field >
185+ <field name =" name" >Condominium : Compute Meter Reading Consumption</field >
186186 </record >
187187 <record id =" industry_update_curr_9c379c6b-889a-4235-af2e-df6e3dcfaa6d" model =" ir.actions.server" >
188188 <field name =" code" ><![CDATA[ for line in record.x_property_id.x_studio_owner_ids:
@@ -192,7 +192,7 @@ for mr in mrs:
192192]]> </field >
193193 <field name =" model_id" ref =" property_line_58f38056-6793-42e3-8f7a-f3db6e3da145" />
194194 <field name =" state" >code</field >
195- <field name =" name" >Industry : Update Property Current Owner</field >
195+ <field name =" name" >Condominium : Update Property Current Owner</field >
196196 <field name =" usage" >base_automation</field >
197197 </record >
198198 <record id =" industry_archive_rel_1116b329-ad32-4a7f-b31c-59702e264ec1" model =" ir.actions.server" >
@@ -202,7 +202,7 @@ for mr in mrs:
202202]]> </field >
203203 <field name =" model_id" ref =" property_9abd67e7-492e-4fac-9aef-812e565e196e" />
204204 <field name =" state" >code</field >
205- <field name =" name" >Industry : Archive related accounts</field >
205+ <field name =" name" >Condominium : Archive related accounts</field >
206206 <field name =" usage" >base_automation</field >
207207 </record >
208208 <record id =" industry_populate_vo_154b8787-f5ce-4bea-931b-a6edbc80a723" model =" ir.actions.server" >
@@ -217,7 +217,7 @@ record['x_studio_attendee_vote_ids'] = env['x_calendar_event_line_a1bce_line_a3f
217217]]> </field >
218218 <field name =" model_id" ref =" calendar_event_line_c0871dc9-8843-41a1-8c07-bbfd5c053508" />
219219 <field name =" state" >code</field >
220- <field name =" name" >Industry : Populate Voters</field >
220+ <field name =" name" >Condominium : Populate Voters</field >
221221 <field name =" usage" >base_automation</field >
222222 </record >
223223 <record id =" industry_set_votes_a_73342a03-85fc-4775-afd2-800be099d3aa" model =" ir.actions.server" >
@@ -227,7 +227,7 @@ record['x_studio_attendee_vote_ids'] = env['x_calendar_event_line_a1bce_line_a3f
227227]]> </field >
228228 <field name =" model_id" ref =" calendar_event_line_c0871dc9-8843-41a1-8c07-bbfd5c053508" />
229229 <field name =" state" >code</field >
230- <field name =" name" >Industry : Set Votes as All Against</field >
230+ <field name =" name" >Condominium : Set Votes as All Against</field >
231231 </record >
232232 <record id =" industry_set_votes_a_d3b6fd79-aef3-4619-9279-4ec49d90559d" model =" ir.actions.server" >
233233 <field name =" binding_model_id" ref =" calendar_event_line_c0871dc9-8843-41a1-8c07-bbfd5c053508" />
@@ -236,83 +236,80 @@ record['x_studio_attendee_vote_ids'] = env['x_calendar_event_line_a1bce_line_a3f
236236]]> </field >
237237 <field name =" model_id" ref =" calendar_event_line_c0871dc9-8843-41a1-8c07-bbfd5c053508" />
238238 <field name =" state" >code</field >
239- <field name =" name" >Industry : Set Votes as All In Favor</field >
239+ <field name =" name" >Condominium : Set Votes as All In Favor</field >
240240 </record >
241241 <record id =" industry_send_genera_2c1dc29b-783e-4233-89c4-0ad81f20c6eb" model =" ir.actions.server" >
242242 <field name =" binding_model_id" ref =" calendar.model_calendar_event" />
243243 <field name =" model_id" ref =" calendar.model_calendar_event" />
244244 <field name =" state" >mail_post</field >
245245 <field name =" template_id" ref =" mail_template_51" />
246- <field name =" name" >Industry : Send General Meeting Report</field >
246+ <field name =" name" >Condominium : Send General Meeting Report</field >
247247 </record >
248248 <record id =" industry_send_genera_636204d5-33e7-437e-99cb-fbc897d72c0e" model =" ir.actions.server" >
249249 <field name =" binding_model_id" ref =" calendar.model_calendar_event" />
250250 <field name =" model_id" ref =" calendar.model_calendar_event" />
251251 <field name =" template_id" ref =" mail_template_52" />
252252 <field name =" state" >mail_post</field >
253- <field name =" name" >Industry : Send General Meeting Agenda</field >
253+ <field name =" name" >Condominium : Send General Meeting Agenda</field >
254254 </record >
255255 <record id =" distribute_costs" model =" ir.actions.server" >
256256 <field name =" binding_model_id" ref =" account.model_account_move" />
257- <field name =" code" ><![CDATA[ def findClosestMeterReading (date, meter_readings):
258- closest_mr = meter_readings[0] # Assume first is a good start
257+ <field name =" code" ><![CDATA[
258+ def findClosestMeterReading(date, meter_readings):
259+ closest_mr = meter_readings[0] # Assume first is a good start
259260 if date:
260- # Take the closest meter reading from date
261261 for mr in meter_readings:
262262 if abs((date - mr.x_date).days) < abs((date - closest_mr.x_date).days): closest_mr = mr
263- else: # Case when owner is still current owner, end date is False, then take the latest readings available
263+ else: # Case when owner is still current owner, end date is False, then take the latest readings available
264264 for mr in meter_readings:
265265 if closest_mr.x_date < mr.x_date: closest_mr = mr
266266 return closest_mr
267- #
267+
268268if not record.x_studio_distribution_key:
269- #raise UserError("A distribution key is required to distribute costs to accounts.")
269+ # raise UserError("A distribution key is required to distribute costs to accounts.")
270270 for aml in record.invoice_line_ids: aml['analytic_distribution'] = {}
271271else:
272- analytic_distribution = {};
272+ analytic_distribution = {}
273273 # Key distribution
274274 if record.x_studio_distribution_key.x_studio_based_on == "Shares" and ((record.x_studio_period_start and record.x_studio_period_end) or (not record.x_studio_period_start and not record.x_studio_period_end)):
275275 x_ratios = record.sudo().x_studio_distribution_key.x_studio_ratio_ids
276276 for ratio in x_ratios.filtered(lambda l: l.x_ratio != 0):
277- for owner in ratio.x_studio_property.x_studio_owner_ids :
277+ for account in ratio.x_studio_property.x_studio_account_ids :
278278 if record.x_studio_period_start and record.x_studio_period_end:
279- # Handle owner changes
280- if owner.x_studio_start_date <= record.x_studio_period_end and (not owner.x_studio_end_date or record.x_studio_period_start <= owner.x_studio_end_date):
281- if not owner.x_studio_end_date : analytic_distribution[owner.x_studio_account.id] = (record.x_studio_period_end - max(owner.x_studio_start_date, record.x_studio_period_start)).days * ratio.x_ratio
282- else: analytic_distribution[owner.x_studio_account.id] = (owner.x_studio_end_date - max(owner.x_studio_start_date, record.x_studio_period_start)).days * ratio.x_ratio
279+ if account.x_studio_start_date <= record.x_studio_period_end and (not account.x_studio_end_date or record.x_studio_period_start <= account.x_studio_end_date):
280+ if not account.x_studio_end_date: analytic_distribution[account.id] = (record.x_studio_period_end - max(account.x_studio_start_date, record.x_studio_period_start)).days * ratio.x_ratio
281+ else: analytic_distribution[account.id] = (account.x_studio_end_date - max(account.x_studio_start_date, record.x_studio_period_start)).days * ratio.x_ratio
283282 else:
284- # Only current owner
285- if owner.x_studio_owner.id == ratio.x_studio_property.x_studio_current_owner.id : analytic_distribution[owner.x_studio_account.id] = ratio.x_ratio
283+ if account.partner_id.id == ratio.x_owner.id: analytic_distribution[account.id] = ratio.x_ratio
286284 # Meter distribution
287285 if record.x_studio_distribution_key.x_studio_based_on == "Meter Readings" and record.x_studio_period_start and record.x_studio_period_end:
288286 for property in env['x_property'].search([]):
289287 meter_reading_ids = [item for item in property.x_studio_meter_reading_ids if item.x_meter_id.id == record.x_studio_distribution_key.x_studio_meter.id]
290288 if len(meter_reading_ids) >= 2:
291- mrstart = findClosestMeterReading(record.x_studio_period_start, property.x_studio_meter_reading_ids)
292- mrend = findClosestMeterReading(record.x_studio_period_end, property.x_studio_meter_reading_ids)
293- for owner in property.x_studio_owner_ids:
294- mrostart = findClosestMeterReading(owner.x_studio_start_date, property.x_studio_meter_reading_ids)
295- mroend = findClosestMeterReading(owner.x_studio_end_date, property.x_studio_meter_reading_ids)
296- if mrostart and mrostart.x_date < mrstart.x_date: mrostart = mrstart
297- if mroend and mrend.x_date < mroend.x_date: mroend = mrend
298- if mrostart and mroend and not (mrend.x_date < mrostart.x_date or mroend.x_date < mroend.x_date):
299- analytic_distribution[owner.x_studio_account.id] = abs(mroend.x_quantity - mrostart.x_quantity)
289+ billstart = findClosestMeterReading(record.x_studio_period_start, meter_reading_ids)
290+ billend = findClosestMeterReading(record.x_studio_period_end, meter_reading_ids)
291+ for account in property.x_studio_account_ids:
292+ mrostart = findClosestMeterReading(account.x_studio_start_date, meter_reading_ids)
293+ if mrostart.x_date < billstart.x_date: mrostart = billstart
294+ if account.x_studio_end_date:
295+ mroend = findClosestMeterReading(account.x_studio_end_date, meter_reading_ids)
296+ if billend.x_date < mroend.x_date: mroend = billend
297+ else: mroend = billend
298+ if not (billend.x_date < mrostart.x_date or billend.x_date < mroend.x_date) and mrostart.x_date != mroend.x_date:
299+ analytic_distribution[account.id] = abs(mroend.x_quantity - mrostart.x_quantity)
300300
301- #else:
302- #raise UserError("Period Start and Period End are required to distribute costs by meter.")
303- #for aml in record.invoice_line_ids: aml['analytic_distribution'] = {}
304301 # Outcome
305302 total_ratio = sum(analytic_distribution.values())
306303 if total_ratio:
307- for key in analytic_distribution: analytic_distribution[key] *= 100 / total_ratio
304+ for key in analytic_distribution: analytic_distribution[key] *= 100 / total_ratio
308305 for aml in record.invoice_line_ids: aml['analytic_distribution'] = analytic_distribution
309306 else:
310307 for aml in record.invoice_line_ids: aml['analytic_distribution'] = {}
311308
312309]]> </field >
313310 <field name =" model_id" ref =" account.model_account_move" />
314311 <field name =" state" >code</field >
315- <field name =" name" >Industry : Distribute Costs</field >
312+ <field name =" name" >Condominium : Distribute Costs</field >
316313 </record >
317314 <record id =" industry_populate_di_1bcb08fe-f6dc-4ea0-9ffc-d4607055470e" model =" ir.actions.server" >
318315 <field name =" binding_model_id" ref =" distribution_key_ebf70cee-4475-4921-a5f1-85e747bc5842" />
@@ -325,7 +322,7 @@ else:
325322]]> </field >
326323 <field name =" model_id" ref =" distribution_key_ebf70cee-4475-4921-a5f1-85e747bc5842" />
327324 <field name =" state" >code</field >
328- <field name =" name" >Industry : Populate Distribution Key</field >
325+ <field name =" name" >Condominium : Populate Distribution Key</field >
329326 </record >
330327 <record id =" industry_compute_dis_a81d25a4-1a4e-4e6d-94d2-cd9ed915b36f" model =" ir.actions.server" >
331328 <field name =" binding_model_id" ref =" distribution_key_ebf70cee-4475-4921-a5f1-85e747bc5842" />
@@ -341,15 +338,15 @@ else:
341338if server_action: server_action.run()]]> </field >
342339 <field name =" model_id" ref =" account.model_account_move" />
343340 <field name =" state" >code</field >
344- <field name =" name" >Industry : Call Distribute Costs on UI update</field >
341+ <field name =" name" >Condominium : Call Distribute Costs on UI update</field >
345342 <field name =" usage" >base_automation</field >
346343 </record >
347344 <record id =" industry_call_distri_1dff37c7-1c90-46cd-be7e-0d935c31d7a6" model =" ir.actions.server" >
348345 <field name =" code" ><![CDATA[ server_action = env['ir.actions.server'].search([('name','=','Industry: Distribute Costs')])
349346if server_action: server_action.run()]]> </field >
350347 <field name =" model_id" ref =" account.model_account_move" />
351348 <field name =" state" >code</field >
352- <field name =" name" >Industry : Call Distribute Costs on save</field >
349+ <field name =" name" >Condominium : Call Distribute Costs on save</field >
353350 <field name =" usage" >base_automation</field >
354351 </record >
355352 <record id =" industry_create_task_47e0cf69-8b12-4e53-b7d5-794639319f20" model =" ir.actions.server" >
@@ -358,6 +355,6 @@ if server_action: server_action.run()]]></field>
358355action = { 'type': 'ir.actions.act_window', 'name': 'Create Task', 'res_model': 'project.task', 'view_mode': 'form', 'view_type': 'form', 'target': 'new', 'context': { 'default_project_id': env['project.project'].search([('partner_id', '=', customer_id)]).id, 'default_name': record.x_name, 'default_user_ids': [env.user.id], 'default_partner_id': customer_id } }]]> </field >
359356 <field name =" model_id" ref =" calendar_event_line_c0871dc9-8843-41a1-8c07-bbfd5c053508" />
360357 <field name =" state" >code</field >
361- <field name =" name" >Industry : Create Task from Motion</field >
358+ <field name =" name" >Condominium : Create Task from Motion</field >
362359 </record >
363360</odoo >
0 commit comments