Skip to content

Commit 3dd8a67

Browse files
committed
[IMP] condominium: cl-34
1 parent 8e71bc0 commit 3dd8a67

File tree

7 files changed

+47
-103
lines changed

7 files changed

+47
-103
lines changed

condominium/__manifest__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
'category': 'Services',
55
'depends': [
66
'account_check_printing',
7-
'account_peppol',
87
'accountant',
98
'appointment',
109
'contacts',
@@ -28,15 +27,14 @@
2827
'data/base_automation.xml',
2928
'data/account_analytic_plan.xml',
3029
'data/ir_filters.xml',
31-
'data/ir_default.xml',
3230
'data/ir_actions_act_window.xml',
33-
'data/ir_actions_act_window_view.xml',
3431
'data/ir_ui_view.xml',
3532
'data/qweb_view.xml',
3633
'data/ir_ui_menu.xml',
3734
'data/ir_model_access.xml',
3835
'data/res_partner.xml',
3936
'data/res_company.xml',
37+
'data/ir_default.xml',
4038
'data/ir_rule.xml',
4139
'data/project_task_type.xml',
4240
'data/documents_folder.xml',

condominium/data/ir_actions_act_window_view.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

condominium/data/ir_actions_server.xml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ for original_analytic_id, note_lines in note_details.items():
7979
Original amount: {original_item.amount}
8080
</p>
8181
"""
82-
8382
# write the note and zero the amount in original analytic account line
8483
original_item.write({"x_notes": note_html.strip(), "amount": 0.0,})
8584
]]> </field>
@@ -91,7 +90,6 @@ for original_analytic_id, note_lines in note_details.items():
9190
<field name="state">code</field>
9291
<field name="code"><![CDATA[split_line_vals = []
9392
amount_total = 0
94-
9593
for analytic_line in records:
9694
amount_total += analytic_line.amount
9795
analytic_amount_split = analytic_line.amount / 2
@@ -167,23 +165,21 @@ else:
167165
<field name="state">code</field>
168166
<field name="name">Condomnium: Create Condominium</field>
169167
</record>
170-
<record id="ir_act_server_split_per_property" model="ir.actions.server">
168+
<record id="ir_act_server_split_so_per_owner" model="ir.actions.server">
171169
<field name="code"><![CDATA[# Get distribution ratios
172170
distributions = record.x_distribution_key.x_ratio_ids
173171
total_distribution = sum(distributions.mapped('x_ratio'))
174172
if total_distribution == 0: raise UserError("Cannot split the Sales Orders because there is is no distribution key and total is null.")
175173
for owner in env['res.partner'].search([('x_companies', 'in', record.company_id.id)]): # One SO per owner
176-
new_so = record.copy({'order_line': False}); new_so_lines = [];
177-
new_so['x_source_sales_order'] = record.id
178-
new_so['partner_id'] = owner.id
174+
new_so = record.copy({'order_line': False, 'x_source_sales_order': record.id, 'partner_id': owner.id}); new_so_lines = [];
179175
for sol in record.order_line: # The lines are re-created using the distribution key and the analytic account corresponding to the property is set
180176
for distribution in distributions:
181177
if distribution.x_owner.id == owner.id:
182178
new_so_lines.append((0, 0, { 'order_id': record.id, 'product_id': sol.product_id.id, 'name': sol.name #+ '\n' + distribution.x_property.x_name
183179
, 'product_uom_qty': sol.product_uom_qty, 'product_uom_id': sol.product_uom_id.id,
184180
'price_unit': sol.price_unit * distribution.x_ratio / total_distribution, 'tax_ids': sol.tax_ids, 'discount': sol.discount, 'analytic_distribution': {distribution.x_account.id: 100} }))
185181
new_so.write({'order_line': new_so_lines})
186-
record['state'] = 'cancel'
182+
record.write({'state': 'cancel'})
187183
]]> </field>
188184
<field name="model_id" ref="sale.model_sale_order"/>
189185
<field name="state">code</field>
@@ -204,11 +200,12 @@ for mr in mrs:
204200
<field name="code"><![CDATA[property_id = record.x_property_id
205201
analytic_account = env['account.analytic.account']
206202
for line in property_id.x_owner_ids:
207-
x_owner_line = line.x_owner
208-
x_owner_line_id = x_owner_line.id
209-
if not line.x_end_date: property_id['x_current_owner'] = x_owner_line
210-
account = analytic_account.search([('x_property', '=', property_id.id), ('partner_id', '=', x_owner_line_id)])
211-
if not account and x_owner_line_id: line['x_account'] = analytic_account.create({'name': f"{property_id.x_name} - {x_owner_line.name}", 'x_property': property_id.id, 'partner_id': x_owner_line_id, 'x_owner_line': line.id}).id
203+
owner = line.x_owner
204+
owner_id = owner.id
205+
if not line.x_end_date: property_id.write({'x_current_owner': owner_id})
206+
if owner: account = analytic_account.search([('x_property', '=', property_id.id), ('partner_id', '=', owner_id)], limit=1)
207+
if not account and owner_id:
208+
line['x_account'] = analytic_account.create({'name': f"{property_id.x_name} - {owner.name}", 'x_property': property_id.id, 'partner_id': owner_id, 'x_owner_line': line.id}).id
212209
]]> </field>
213210
<field name="model_id" ref="model_x_property_line_owner"/>
214211
<field name="state">code</field>

condominium/data/ir_default.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
<field name="field_id" ref="active_distribution_field"/>
2121
<field name="json_value">true</field>
2222
</record>
23-
<record id="default_company_distribution" model="ir.default">
23+
<record id="default_x_company_id_main_company" model="ir.default">
2424
<field name="field_id" ref="company_distribution_field"/>
25-
<field name="json_value">1</field>
25+
<field name="json_value" eval="ref('base.main_company')"/>
2626
</record>
27-
<record id="company_distribution_default" model="ir.default">
27+
<record id="default_x_company_id_res_company_4" model="ir.default">
2828
<field name="field_id" ref="company_distribution_field"/>
29-
<field name="json_value">4</field>
29+
<field name="json_value" eval="ref('res_company_4')"/>
3030
</record>
31-
<record id="company_default_distribution" model="ir.default">
31+
<record id="default_x_company_id_res_company_3" model="ir.default">
3232
<field name="field_id" ref="company_distribution_field"/>
33-
<field name="json_value">3</field>
33+
<field name="json_value" eval="ref('res_company_3')"/>
3434
</record>
35-
<record id="company_distribution" model="ir.default">
35+
<record id="default_x_company_id_res_company_2" model="ir.default">
3636
<field name="field_id" ref="company_distribution_field"/>
37-
<field name="json_value">2</field>
37+
<field name="json_value" eval="ref('res_company_2')"/>
3838
</record>
3939
<record id="default_sequence_distributio" model="ir.default">
4040
<field name="field_id" ref="sequence_distributio_field"/>

condominium/data/ir_ui_view.xml

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<field name="arch" type="xml">
1212
<data>
1313
<xpath expr="//field[@name='code']" position="replace"/>
14+
<xpath expr="//form//label[@for='name']" position="replace"/>
1415
<xpath expr="//field[@name='name']" position="attributes">
1516
<attribute name="placeholder">e.g. Apartment A0</attribute>
1617
</xpath>
@@ -19,10 +20,9 @@
1920
<field string="Vendor Bills" name="vendor_bill_count" widget="statinfo"/>
2021
</button>
2122
</xpath>
22-
<xpath expr="//form[1]/sheet[1]/div[not(@name)][1]/label[1]" position="replace"/>
2323
<xpath expr="//button[@name='action_view_projects']" position="replace"/>
2424
<xpath expr="//field[@name='active']" position="after">
25-
<xpath expr="//form[1]/sheet[1]/group[@name='main']/group[2]/field[@name='company_id']" position="move"/>
25+
<xpath expr="//group[@name='main']/group[2]/field[@name='company_id']" position="move"/>
2626
<field name="x_condominium"/>
2727
</xpath>
2828
<xpath expr="//field[@name='currency_id']" position="replace">
@@ -38,7 +38,7 @@
3838
<xpath expr="//field[@name='plan_id']" position="attributes">
3939
<attribute name="invisible">True</attribute>
4040
</xpath>
41-
<xpath expr="//form[1]/sheet[1]/group[@name='main']/group[1]/field[@name='company_id']" position="attributes">
41+
<xpath expr="//group[@name='main']/group/field[@name='company_id']" position="attributes">
4242
<attribute name="force_save">1</attribute>
4343
<attribute name="groups">base.group_no_one</attribute>
4444
<attribute name="readonly">True</attribute>
@@ -56,7 +56,7 @@
5656
<field name="type">form</field>
5757
<field name="arch" type="xml">
5858
<xpath expr="//header" position="inside">
59-
<button name="%(ir_act_server_split_per_property)d" string="Split per Owner" type="action" invisible="not x_company_partner_id or state != 'draft'"/>
59+
<button name="%(ir_act_server_split_so_per_owner)d" string="Split per Owner" type="action" invisible="not x_company_partner_id or state != 'draft'"/>
6060
</xpath>
6161
<xpath expr="//button[@name='action_sale_order_log']" position="after">
6262
<button name="%(sale_order_button_action)d" class="oe_stat_button" icon="fa-dollar" type="action" invisible="x_source_sales_order_sale_order_count == 0">
@@ -336,7 +336,7 @@
336336
<field name="priority">99</field>
337337
<field name="type">list</field>
338338
<field name="arch" type="xml">
339-
<xpath expr="//list[1]/field[@name='name']" position="attributes">
339+
<xpath expr="//field[@name='name']" position="attributes">
340340
<attribute name="string">Distribution Key</attribute>
341341
</xpath>
342342
<xpath expr="//field[@name='country_group_ids']" position="attributes">
@@ -369,7 +369,7 @@
369369
<xpath expr="//field[@name='property_product_pricelist']" position="after">
370370
<field name="x_condominium_properties" widget="many2many_tags" force_save="1" readonly="True" />
371371
</xpath>
372-
<xpath expr="//form[1]/sheet[1]/notebook[1]" position="inside">
372+
<xpath expr="//sheet/notebook" position="inside">
373373
<page string="Vendors" invisible="not ref_company_ids">
374374
<field name="x_vendors">
375375
<list string="Contacts" sample="1" multi_edit="1" editable="bottom">
@@ -422,16 +422,16 @@
422422
<xpath expr="//field[@name='sale_order_template_id']" position="after">
423423
<field name="x_distribution_key" options="{'create_name_field': 'x_name'}"/>
424424
</xpath>
425-
<xpath expr="//form[1]/sheet[1]/group[@name='sale_header']/group[@name='order_details']/label[not(@name)][1]" position="attributes">
425+
<xpath expr="//label[@for='pricelist_id']" position="attributes">
426426
<attribute name="string">Pricelist</attribute>
427427
</xpath>
428-
<xpath expr="//form[1]/sheet[1]/group[@name='sale_header']/group[@name='order_details']/div[not(@name)][3]/field[@name='pricelist_id']" position="attributes">
428+
<xpath expr="//field[@name='pricelist_id']" position="attributes">
429429
<attribute name="placeholder"/>
430430
</xpath>
431431
<xpath expr="//group[@name='sale_header']" position="after">
432432
<group name="sale_header_group"/>
433433
</xpath>
434-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/list[1]" position="attributes">
434+
<xpath expr="//page[@name='order_lines']/field[@name='order_line']/list" position="attributes">
435435
<attribute name="open_form_view">true</attribute>
436436
</xpath>
437437
</data>
@@ -727,7 +727,7 @@
727727
<record id="analytic_account_custom_list_view" model="ir.ui.view">
728728
<field name="arch" type="xml">
729729
<data>
730-
<xpath expr="//list[1]/field[@name='company_id'][2]" position="replace"/>
730+
<xpath expr="//field[@name='company_id' and @groups='base.group_multi_company']" position="replace"/>
731731
<xpath expr="//field[@name='plan_id']" position="replace"/>
732732
<xpath expr="//field[@name='code']" position="replace">
733733
<field name="x_start_date" optional="show"/>
@@ -770,12 +770,12 @@
770770
<record id="view_account_analytic_line_form_inherit" model="ir.ui.view">
771771
<field name="arch" type="xml">
772772
<data>
773-
<xpath expr="//form[1]/field[@name='company_id']" position="before">
773+
<xpath expr="//field[@name='company_id']" position="before">
774774
<header>
775775
<button string="Split" name="%(split_analytic_item_action)d" type="action" class="btn-primary"/>
776776
</header>
777777
</xpath>
778-
<xpath expr="//form[1]/sheet[1]/group[1]/group[@name='analytic_item']/field[@name='company_id']" position="after">
778+
<xpath expr="//group[@name='analytic_item']/field[@name='company_id']" position="after">
779779
<field name="x_notes"/>
780780
</xpath>
781781
<xpath expr="//field[@name='product_id']" position="after">
@@ -1006,24 +1006,15 @@
10061006
<xpath expr="//page[@name='page_invitations']" position="attributes">
10071007
<attribute name="groups"/>
10081008
</xpath>
1009-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='page_invitations']/field[@name='attendee_ids']/list[1]/field[@name='partner_id']" position="attributes">
1010-
<attribute name="readonly">True</attribute>
1011-
</xpath>
1012-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='page_invitations']/field[@name='attendee_ids']/list[1]/field[@name='email']" position="attributes">
1013-
<attribute name="readonly">True</attribute>
1014-
</xpath>
1015-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='page_invitations']/field[@name='attendee_ids']/list[1]/field[@name='phone']" position="attributes">
1016-
<attribute name="readonly">True</attribute>
1017-
</xpath>
1018-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='page_invitations']/field[@name='attendee_ids']/list[1]/field[@name='state']" position="attributes">
1009+
<xpath expr="//field[@name='attendee_ids']" position="attributes">
10191010
<attribute name="readonly">True</attribute>
10201011
</xpath>
1021-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='page_invitations']/field[@name='attendee_ids']/list[1]/button[@name='do_decline']" position="after">
1012+
<xpath expr="//field[@name='attendee_ids']/list/button[@name='do_decline']" position="after">
10221013
<field name="x_attending" invisible="not x_condominium"/>
10231014
<field optional="show" name="x_delegating" invisible="not x_condominium"/>
10241015
<field name="x_ratio" optional="show"/>
10251016
</xpath>
1026-
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='page_invitations']/field[@name='attendee_ids']/kanban[1]" position="after">
1017+
<xpath expr="//field[@name='attendee_ids']/kanban" position="after">
10271018
<form>
10281019
<sheet string="Calendar Attendee Information" name="calendar_attendee_information_sheet">
10291020
<group name="calendar_attendee_information_group">
@@ -1056,7 +1047,7 @@
10561047
</sheet>
10571048
</form>
10581049
</xpath>
1059-
<xpath expr="//form[1]/sheet[1]/notebook[1]" position="inside">
1050+
<xpath expr="//form/sheet/notebook" position="inside">
10601051
<page string="Motions" name="motions_page" invisible="not x_condominium">
10611052
<group name="motions_group_main">
10621053
<group name="motions_group_left">
@@ -1216,14 +1207,14 @@
12161207
<record id="view_invoice_tree_inherit" model="ir.ui.view">
12171208
<field name="arch" type="xml">
12181209
<data>
1219-
<xpath expr="//list[1]" position="attributes">
1210+
<xpath expr="//list" position="attributes">
12201211
<attribute name="create">false</attribute>
12211212
<attribute name="default_order">invoice_date desc</attribute>
12221213
<attribute name="delete">false</attribute>
12231214
<attribute name="multi_edit">true</attribute>
12241215
<attribute name="open_form_view">true</attribute>
12251216
</xpath>
1226-
<xpath expr="//list[1]/field[@name='name']" position="attributes">
1217+
<xpath expr="//list/field[@name='name']" position="attributes">
12271218
<attribute name="readonly">True</attribute>
12281219
</xpath>
12291220
<xpath expr="//field[@name='name']" position="after">
@@ -1237,7 +1228,7 @@
12371228
<attribute name="string">Total</attribute>
12381229
</xpath>
12391230
<xpath expr="//field[@name='invoice_partner_display_name']" position="after">
1240-
<xpath expr="//list[1]/field[@name='amount_total_in_currency_signed']" position="move"/>
1231+
<xpath expr="//list/field[@name='amount_total_in_currency_signed']" position="move"/>
12411232
<field name="x_distribution_key" optional="show"/>
12421233
<field name="x_period_start" optional="show"/>
12431234
<field name="x_period_end" optional="show"/>
@@ -1273,7 +1264,7 @@
12731264
<xpath expr="//filter[@name='not_sent']" position="replace"/>
12741265
<xpath expr="//field[@name='line_ids']" position="replace"/>
12751266
<xpath expr="//field[@name='next_payment_date']" position="replace"/>
1276-
<xpath expr="//search[1]/field[@name='date']" position="replace"/>
1267+
<xpath expr="//search/field[@name='date']" position="replace"/>
12771268
<xpath expr="//field[@name='invoice_user_id']" position="replace"/>
12781269
<xpath expr="//field[@name='journal_group_id']" position="replace"/>
12791270
<xpath expr="//field[@name='journal_id']" position="replace"/>
@@ -1284,6 +1275,8 @@
12841275
<filter domain="[('x_distribution_key', '=', False)]" name="undistributed" help="Without distribution"/>
12851276
<separator/>
12861277
</xpath>
1278+
<xpath expr="//filter[@name='draft']" position="replace"/>
1279+
<xpath expr="//filter[@name='partner']" position="replace"/>
12871280
</data>
12881281
</field>
12891282
<field name="inherit_id" ref="account.view_account_invoice_filter"/>
@@ -1470,7 +1463,6 @@
14701463
</form>
14711464
</field>
14721465
</record>
1473-
14741466
<record id="properties_act_window_account" model="ir.actions.act_window">
14751467
<field name="view_ids" eval="[
14761468
(5, 0, 0),

0 commit comments

Comments
 (0)