Skip to content

Commit f375863

Browse files
committed
[IMP] condominium: cleanup14
1 parent 051d02f commit f375863

File tree

9 files changed

+186
-123
lines changed

9 files changed

+186
-123
lines changed

condominium/data/account_analytic_line.xml

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

condominium/data/ir_actions_server.xml

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
268268
if 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'] = {}
271271
else:
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:
341338
if 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')])
349346
if 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>
358355
action = { '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>

condominium/data/ir_ui_view.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@
403403
<field widget="statinfo" name="x_x_studio_condominium_x_property_count" string="Properties"/>
404404
</button>
405405
</xpath> -->
406+
<xpath expr="//button[@name='action_see_documents']" position="after">
407+
<button class="oe_stat_button" icon="fa-home" type="action" name="%(owner_properties_contact_smart_button)d" invisible="not x_x_studio_current_owner_x_property_count">
408+
<field widget="statinfo" name="x_x_studio_current_owner_x_property_count" string="Properties"/>
409+
</button>
410+
</xpath>
406411
<xpath expr="//field[@name='child_ids']" position="after">
407412
<field name="x_studio_ownership_properties"/>
408413
<field name="x_studio_co_ownership_properties"/>

condominium/data/project_task.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<field name="sequence" eval="False"/>
66
<field name="project_id" ref="project_project_5"/>
77
<field name="stage_id" ref="project_task_type_17"/>
8-
<field name="date_assign">2025-04-22 11:36:30</field>
98
<field name="partner_id" ref="res_partner_7"/>
109
</record>
1110
<record id="project_task_15" model="project.task">
@@ -19,7 +18,6 @@
1918
<field name="sequence">1</field>
2019
<field name="project_id" ref="project_project_5"/>
2120
<field name="stage_id" ref="project_task_type_17"/>
22-
<field name="date_assign">2025-04-22 11:36:30</field>
2321
<field name="partner_id" ref="res_partner_7"/>
2422
</record>
2523
<record id="project_task_14" model="project.task">
@@ -33,7 +31,6 @@
3331
<field name="sequence">2</field>
3432
<field name="project_id" ref="project_project_5"/>
3533
<field name="stage_id" ref="project_task_type_17"/>
36-
<field name="date_assign">2025-04-22 11:36:30</field>
3734
<field name="partner_id" ref="res_partner_7"/>
3835
</record>
3936
<record id="project_task_13" model="project.task">
@@ -47,7 +44,6 @@
4744
<field name="sequence">3</field>
4845
<field name="project_id" ref="project_project_5"/>
4946
<field name="stage_id" ref="project_task_type_17"/>
50-
<field name="date_assign">2025-04-22 11:36:30</field>
5147
<field name="partner_id" ref="res_partner_7"/>
5248
</record>
5349
<record id="project_task_12" model="project.task">
@@ -61,7 +57,6 @@
6157
<field name="sequence">4</field>
6258
<field name="project_id" ref="project_project_5"/>
6359
<field name="stage_id" ref="project_task_type_17"/>
64-
<field name="date_assign">2025-04-22 11:36:30</field>
6560
<field name="partner_id" ref="res_partner_7"/>
6661
</record>
6762
<record id="project_task_11" model="project.task">
@@ -75,7 +70,6 @@
7570
<field name="sequence">5</field>
7671
<field name="project_id" ref="project_project_5"/>
7772
<field name="stage_id" ref="project_task_type_17"/>
78-
<field name="date_assign">2025-04-22 11:36:30</field>
7973
<field name="partner_id" ref="res_partner_7"/>
8074
</record>
8175
<record id="project_task_10" model="project.task">

condominium/data/x_distribution_key.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<field name="x_name">Electricity</field>
3030
<field name="x_studio_company_id" ref="res_company_2"/>
3131
<field name="x_studio_based_on">Meter Readings</field>
32-
<field name="x_studio_meter" ref="x_meters_elec"/>
32+
<field name="x_studio_meter" ref="x_meters_water"/>
3333
</record>
3434
<record id="x_distribution_key_9" model="x_distribution_key">
3535
<field name="x_name">Default</field>

condominium/demo/account_move.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</record>
2929
<record id="account_move_316" model="account.move">
3030
<field name="posted_before" eval="True"/>
31-
<field name="invoice_date">2025-05-13</field>
31+
<!-- <field name="invoice_date">2025-05-13</field> -->
3232
<field name="company_id" ref="res_company_2"/>
3333
<!-- <field name="journal_id" ref="account.2_purchase"/> -->
3434
<field name="move_type">in_invoice</field>
@@ -43,7 +43,7 @@
4343
</record>
4444
<record id="account_move_315" model="account.move">
4545
<field name="posted_before" eval="True"/>
46-
<field name="invoice_date">2025-05-13</field>
46+
<!-- <field name="invoice_date">2025-05-13</field> -->
4747
<field name="company_id" ref="res_company_2"/>
4848
<field name="partner_id" ref="res_partner_37"/>
4949
<!-- <field name="journal_id" ref="account.2_purchase"/> -->
@@ -54,7 +54,7 @@
5454
<!-- <field name="invoice_partner_display_name">Sibelga</field> -->
5555
<field name="is_manually_modified" eval="True"/>
5656
<!-- <field name="x_studio_meter" ref="x_meters_elec"/> -->
57-
<field name="x_studio_period_start">2024-01-01</field>
58-
<field name="x_studio_period_end">2025-01-02</field>
57+
<field name="x_studio_period_start" eval="datetime.today().date() - relativedelta(years=2)"/>
58+
<field name="x_studio_period_end" eval="datetime.today().date() - relativedelta(years=1)"/>
5959
</record>
6060
</odoo>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<odoo>
33
<!--Update sale order stages-->
4-
<function model="account.move" name="action_post" eval="[[ref('account_move_315'), ref('account_move_316'), ref('account_move_317'), ref('account_move_319')]]"/>
4+
<function model="account.move" name="action_post" eval="[[ref('account_move_316'), ref('account_move_317'), ref('account_move_319')]]"/>
55
</odoo>

0 commit comments

Comments
 (0)