Skip to content

Commit

Permalink
[12.0][IMP] Improved code as per @mayank's comment added undefine par…
Browse files Browse the repository at this point in the history
…tner and set to customer_id.
  • Loading branch information
nikitavaghela committed Jan 20, 2020
1 parent 29deb3e commit 61276df
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions connector_alndata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
from .init_hook import pre_init_hook
3 changes: 3 additions & 0 deletions connector_alndata/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
'depends': [
'crm',
'fieldservice',
'account',
],
'data': [
'data/ir_config_parameter_data.xml',
'data/res_partner_data.xml',
'data/sync_aln_data_view.xml',
'views/res_partner_industry_view.xml',
'views/res_partner_view.xml',
],
'installable': True,
'pre_init_hook': 'pre_init_hook',
}
25 changes: 25 additions & 0 deletions connector_alndata/data/res_partner_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<odoo>
<!-- Undefine Receivable Account -->
<record id="undefine_receivable_account" model="account.account">
<field name="name">Undefine Receivable Account</field>
<field name="code">100101</field>
<field name="user_type_id" ref="account.data_account_type_receivable"/>
<field name="reconcile">True</field>
</record>

<!-- Undefine Payable Account -->
<record id="undefine_payable_account" model="account.account">
<field name="name">Undefine Payable Account</field>
<field name="code">100102</field>
<field name="user_type_id" ref="account.data_account_type_payable"/>
<field name="reconcile">True</field>
</record>

<!-- Undefine Customer to set in customer_id field -->
<record id="undefined_customer" model="res.partner">
<field name="name">Undefine</field>
<field name="property_account_receivable_id" ref="undefine_receivable_account"/>
<field name="property_account_payable_id" ref="undefine_payable_account"/>
</record>

</odoo>
8 changes: 8 additions & 0 deletions connector_alndata/init_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


def pre_init_hook(cr):
cr.execute("""ALTER TABLE "fsm_location" ADD "customer_id" INT;""")
cr.execute("""UPDATE "fsm_location" SET customer_id = owner_id
WHERE customer_id IS NULL;""")
6 changes: 5 additions & 1 deletion connector_alndata/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,18 @@ def sync_apartment_data(self):
{
'commercial_partner_id': management_company and
management_company.id})
customer_id = self.env.ref(
'connector_alndata.undefined_customer')
apartment_vals.update({'customer_id': customer_id.id})
if prop.get('OwnerId'):
owner = partner_obj.search(
[('ref', '=', prop.get('OwnerId')),
('partner_type', '=', 'owner')],
limit=1)
apartment_vals.update(
{
'owner_id': owner and owner.id})
'owner_id': owner and owner.id,
'customer_id': (owner and owner.id) or customer_id.id})
if apart.get('Addresses', False):
address = apart['Addresses'][0]
state = self.get_state(state_obj,
Expand Down
3 changes: 3 additions & 0 deletions connector_alndata/models/fsm_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ class FsmLocation(models.Model):
owner_id = fields.Many2one('res.partner', string='Related Owner',
required=False, ondelete='restrict',
auto_join=True)
customer_id = fields.Many2one(
'res.partner', string='Billed Customer', required=True,
ondelete='restrict', auto_join=True, track_visibility='onchange')

0 comments on commit 61276df

Please sign in to comment.