[Merge] Merge with main branch
bzr revid: kjo@tinyerp.com-20120305132335-253i91o7ykasm29q
This commit is contained in:
@@ -146,7 +146,7 @@ module named account_voucher.
|
||||
'test/account_fiscalyear_close.yml',
|
||||
'test/account_bank_statement.yml',
|
||||
'test/account_cash_statement.yml',
|
||||
'test/test_edi_invoice.yml',
|
||||
# 'test/test_edi_invoice.yml', it will be need to check
|
||||
'test/account_report.yml',
|
||||
'test/account_fiscalyear_close_state.yml', #last test, as it will definitively close the demo fiscalyear
|
||||
],
|
||||
|
||||
@@ -1963,8 +1963,8 @@ class account_tax(osv.osv):
|
||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults = {
|
||||
'python_compute': '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''',
|
||||
'python_compute_inv': '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''',
|
||||
'python_compute': '''# price_unit\n# address: res.partner object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''',
|
||||
'python_compute_inv': '''# price_unit\n# address: res.partner object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''',
|
||||
'applicable_type': 'true',
|
||||
'type': 'percent',
|
||||
'amount': 0,
|
||||
@@ -1983,7 +1983,7 @@ class account_tax(osv.osv):
|
||||
|
||||
def _applicable(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||
res = []
|
||||
obj_partener_address = self.pool.get('res.partner.address')
|
||||
obj_partener_address = self.pool.get('res.partner')
|
||||
for tax in taxes:
|
||||
if tax.applicable_type=='code':
|
||||
localdict = {'price_unit':price_unit, 'address':obj_partener_address.browse(cr, uid, address_id), 'product':product, 'partner':partner}
|
||||
@@ -1998,7 +1998,7 @@ class account_tax(osv.osv):
|
||||
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||
res = []
|
||||
cur_price_unit=price_unit
|
||||
obj_partener_address = self.pool.get('res.partner.address')
|
||||
obj_partener_address = self.pool.get('res.partner')
|
||||
for tax in taxes:
|
||||
# we compute the amount for the current tax object and append it to the result
|
||||
data = {'id':tax.id,
|
||||
@@ -2125,7 +2125,7 @@ class account_tax(osv.osv):
|
||||
|
||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||
obj_partener_address = self.pool.get('res.partner.address')
|
||||
obj_partener_address = self.pool.get('res.partner')
|
||||
res = []
|
||||
taxes.reverse()
|
||||
cur_price_unit = price_unit
|
||||
@@ -2806,8 +2806,8 @@ class account_tax_template(osv.osv):
|
||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults = {
|
||||
'python_compute': lambda *a: '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''',
|
||||
'python_compute_inv': lambda *a: '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''',
|
||||
'python_compute': lambda *a: '''# price_unit\n# address: res.partner object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''',
|
||||
'python_compute_inv': lambda *a: '''# price_unit\n# address: res.partner object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''',
|
||||
'applicable_type': 'true',
|
||||
'type': 'percent',
|
||||
'amount': 0,
|
||||
|
||||
@@ -216,8 +216,6 @@ class account_invoice(osv.osv):
|
||||
help="If you use payment terms, the due date will be computed automatically at the generation "\
|
||||
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}),
|
||||
'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly',False)]}),
|
||||
'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]},
|
||||
help="If you use payment terms, the due date will be computed automatically at the generation "\
|
||||
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "\
|
||||
@@ -396,7 +394,6 @@ class account_invoice(osv.osv):
|
||||
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
|
||||
date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
|
||||
invoice_addr_id = False
|
||||
contact_addr_id = False
|
||||
partner_payment_term = False
|
||||
acc_id = False
|
||||
bank_id = False
|
||||
@@ -406,8 +403,8 @@ class account_invoice(osv.osv):
|
||||
if partner_id:
|
||||
|
||||
opt.insert(0, ('id', partner_id))
|
||||
res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['contact', 'invoice'])
|
||||
contact_addr_id = res['contact']
|
||||
res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['invoice'])
|
||||
print "-=res",res
|
||||
invoice_addr_id = res['invoice']
|
||||
p = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
if company_id:
|
||||
@@ -442,8 +439,6 @@ class account_invoice(osv.osv):
|
||||
bank_id = p.bank_ids[0].id
|
||||
|
||||
result = {'value': {
|
||||
'address_contact_id': contact_addr_id,
|
||||
'address_invoice_id': invoice_addr_id,
|
||||
'account_id': acc_id,
|
||||
'payment_term': partner_payment_term,
|
||||
'fiscal_position': fiscal_position
|
||||
@@ -1092,7 +1087,7 @@ class account_invoice(osv.osv):
|
||||
return map(lambda x: (0,0,x), lines)
|
||||
|
||||
def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
|
||||
invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id'])
|
||||
invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id'])
|
||||
obj_invoice_line = self.pool.get('account.invoice.line')
|
||||
obj_invoice_tax = self.pool.get('account.invoice.tax')
|
||||
obj_journal = self.pool.get('account.journal')
|
||||
@@ -1140,7 +1135,7 @@ class account_invoice(osv.osv):
|
||||
'name': description,
|
||||
})
|
||||
# take the id part of the tuple returned for many2one fields
|
||||
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
|
||||
for field in ('partner_id',
|
||||
'account_id', 'currency_id', 'payment_term', 'journal_id'):
|
||||
invoice[field] = invoice[field] and invoice[field][0]
|
||||
# create the new invoice
|
||||
@@ -1257,7 +1252,7 @@ class account_invoice_line(osv.osv):
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
for line in self.browse(cr, uid, ids):
|
||||
price = line.price_unit * (1-(line.discount or 0.0)/100.0)
|
||||
taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id)
|
||||
taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, partner=line.invoice_id.partner_id)
|
||||
res[line.id] = taxes['total']
|
||||
if line.invoice_id:
|
||||
cur = line.invoice_id.currency_id
|
||||
@@ -1277,7 +1272,7 @@ class account_invoice_line(osv.osv):
|
||||
taxes = l[2].get('invoice_line_tax_id')
|
||||
if len(taxes[0]) >= 3 and taxes[0][2]:
|
||||
taxes = tax_obj.browse(cr, uid, list(taxes[0][2]))
|
||||
for tax in tax_obj.compute_all(cr, uid, taxes, p,l[2].get('quantity'), context.get('address_invoice_id', False), l[2].get('product_id', False), context.get('partner_id', False))['taxes']:
|
||||
for tax in tax_obj.compute_all(cr, uid, taxes, p,l[2].get('quantity'), l[2].get('product_id', False), context.get('partner_id', False))['taxes']:
|
||||
t = t - tax['amount']
|
||||
return t
|
||||
return 0
|
||||
@@ -1322,7 +1317,7 @@ class account_invoice_line(osv.osv):
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None):
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
company_id = company_id if company_id != None else context.get('company_id',False)
|
||||
@@ -1404,7 +1399,7 @@ class account_invoice_line(osv.osv):
|
||||
context = dict(context)
|
||||
context.update({'company_id': company_id})
|
||||
warning = {}
|
||||
res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context=context)
|
||||
res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context)
|
||||
if 'uos_id' in res['value']:
|
||||
del res['value']['uos_id']
|
||||
if not uom:
|
||||
@@ -1437,7 +1432,7 @@ class account_invoice_line(osv.osv):
|
||||
tax_code_found= False
|
||||
for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id,
|
||||
(line.price_unit * (1.0 - (line['discount'] or 0.0) / 100.0)),
|
||||
line.quantity, inv.address_invoice_id.id, line.product_id,
|
||||
line.quantity, line.product_id,
|
||||
inv.partner_id)['taxes']:
|
||||
|
||||
if inv.type in ('out_invoice', 'in_invoice'):
|
||||
@@ -1572,7 +1567,7 @@ class account_invoice_tax(osv.osv):
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
|
||||
for line in inv.invoice_line:
|
||||
for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id)['taxes']:
|
||||
for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, line.product_id, inv.partner_id)['taxes']:
|
||||
tax['price_unit'] = cur_obj.round(cr, uid, cur, tax['price_unit'])
|
||||
val={}
|
||||
val['invoice_id'] = inv.id
|
||||
|
||||
@@ -51,12 +51,12 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Invoice Line">
|
||||
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, context, parent.company_id)"/>
|
||||
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
<field colspan="2" name="name"/>
|
||||
<label string="Quantity :" align="1.0"/>
|
||||
<group colspan="1" col="2">
|
||||
<field name="quantity" nolabel="1"/>
|
||||
<field name="uos_id" on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, context, parent.company_id)" nolabel="1"/>
|
||||
<field name="uos_id" on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_contact_id, parent.currency_id, context, parent.company_id)" nolabel="1"/>
|
||||
</group>
|
||||
<field name="price_unit"/>
|
||||
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
|
||||
@@ -152,8 +152,7 @@
|
||||
<field name="currency_id" width="50"/>
|
||||
<button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
|
||||
<newline/>
|
||||
<field string="Supplier" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" options='{"quick_create": false}' domain="[('supplier', '=', True)]"/>
|
||||
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id" context="{'default_partner_id': partner_id}" options='{"quick_create": false}'/>
|
||||
<field string="Supplier Name" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" options='{"quick_create": false}' domain="[('supplier', '=', True)]"/>
|
||||
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
|
||||
<newline/>
|
||||
<field name="date_invoice"/>
|
||||
@@ -168,9 +167,9 @@
|
||||
<field name="reference_type" nolabel="1" size="0"/>
|
||||
<field name="reference" nolabel="1"/>
|
||||
<field name="date_due"/>
|
||||
<field colspan="4" context="{'address_invoice_id': address_invoice_id, 'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False, 'type': type}" name="invoice_line" nolabel="1">
|
||||
<field colspan="4" context="{'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False, 'type': type}" name="invoice_line" nolabel="1">
|
||||
<tree string="Invoice lines">
|
||||
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, context, parent.company_id)"/>
|
||||
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id" on_change="onchange_account_id(product_id,parent.partner_id,parent.type,parent.fiscal_position,account_id)"/>
|
||||
<field name="invoice_line_tax_id" view_mode="2" context="{'type':parent.type}" domain="[('parent_id','=',False)]"/>
|
||||
<field domain="[('type','<>','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||
@@ -223,7 +222,6 @@
|
||||
<field name="name"/>
|
||||
<newline/>
|
||||
<field name="origin" groups="base.group_extended"/>
|
||||
<field domain="[('partner_id','=',partner_id)]" name="address_contact_id" groups="base.group_extended"/>
|
||||
<field name="user_id"/>
|
||||
<field name="move_id" groups="account.group_account_user"/>
|
||||
<separator colspan="4" string="Additional Information"/>
|
||||
@@ -262,8 +260,7 @@
|
||||
<field name="currency_id" width="50"/>
|
||||
<button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
|
||||
<newline/>
|
||||
<field string="Customer" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" groups="base.group_user" context="{'search_default_customer': 1}" options='{"quick_create": false}' domain="[('customer', '=', True)]"/>
|
||||
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id" context="{'default_partner_id': partner_id}" options='{"quick_create": false}'/>
|
||||
<field string="Customer Name" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" groups="base.group_user" context="{'search_default_customer': 1}" options='{"quick_create": false}' domain="[('customer', '=', True)]"/>
|
||||
<field name="fiscal_position" groups="base.group_extended" widget="selection" options='{"quick_create": false}'/>
|
||||
<newline/>
|
||||
<field name="date_invoice"/>
|
||||
@@ -321,8 +318,6 @@
|
||||
<field domain="[('partner_id.ref_companies', 'in', [company_id])]" name="partner_bank_id"
|
||||
groups="base.group_extended"/>
|
||||
<field name="origin"/>
|
||||
<field colspan="4" domain="[('partner_id','=',partner_id)]" name="address_contact_id"
|
||||
groups="base.group_extended"/>
|
||||
<field name="move_id" groups="account.group_account_user"/>
|
||||
<separator colspan="4" string="Additional Information"/>
|
||||
<field colspan="4" name="comment" nolabel="1"/>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo'))
|
||||
part = self.pool.get('res.partner').browse(cr, uid, ref('base.main_partner'))
|
||||
# if we know the country and the wizard has not yet been executed, we do it
|
||||
if (part.country.id) and (wiz.state=='open'):
|
||||
mod = 'l10n_'+part.country.code.lower()
|
||||
if (part.country_id.id) and (wiz.state=='open'):
|
||||
mod = 'l10n_'+part.country_id.co7de.lower()
|
||||
ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context)
|
||||
if ids:
|
||||
wizards.write(cr, uid, [ref('account.account_configuration_installer_todo')], {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<record id="test_invoice_1" model="account.invoice">
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="address_invoice_id" ref="base.res_partner_address_tang"/>
|
||||
<field name="partner_id" ref="base.res_partner_asus"/>
|
||||
<field name="journal_id" ref="account.sales_journal"/>
|
||||
<field name="state">draft</field>
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
<field name="payment_term" ref="account.account_payment_term"/>
|
||||
<field name="journal_id" ref="account.expenses_journal"/>
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
<field name="address_invoice_id" ref="base.res_partner_address_wong"/>
|
||||
<field name="user_id" ref="base.user_demo"/>
|
||||
<field name="address_contact_id" ref="base.res_partner_address_wong"/>
|
||||
<field name="reference_type">none</field>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="state">draft</field>
|
||||
|
||||
@@ -75,7 +75,7 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
"""Exports a supplier or customer invoice"""
|
||||
edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT)
|
||||
res_company = self.pool.get('res.company')
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
res_partner_address = self.pool.get('res.partner')
|
||||
edi_doc_list = []
|
||||
for invoice in records:
|
||||
# generate the main report
|
||||
@@ -84,7 +84,7 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
edi_doc.update({
|
||||
'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context),
|
||||
'company_paypal_account': invoice.company_id.paypal_account,
|
||||
'partner_address': res_partner_address.edi_export(cr, uid, [invoice.address_invoice_id], context=context)[0],
|
||||
'partner_address': res_partner_address.edi_export(cr, uid, [invoice.partner_id], context=context)[0],
|
||||
|
||||
'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_id], context=context)[0],
|
||||
'partner_ref': invoice.reference or False,
|
||||
@@ -125,7 +125,6 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
# the desired company among the user's allowed companies
|
||||
|
||||
self._edi_requires_attributes(('company_id','company_address','type'), edi_document)
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company = new partner
|
||||
@@ -144,13 +143,13 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['partner_id'] = (src_company_id, src_company_name)
|
||||
address_info['type'] = 'invoice'
|
||||
address_id = res_partner_address.edi_import(cr, uid, address_info, context=context)
|
||||
address_id = res_partner.edi_import(cr, uid, address_info, context=context)
|
||||
|
||||
# modify edi_document to refer to new partner
|
||||
partner_address = res_partner_address.browse(cr, uid, address_id, context=context)
|
||||
partner_address = res_partner.browse(cr, uid, address_id, context=context)
|
||||
edi_document['partner_id'] = (src_company_id, src_company_name)
|
||||
edi_document.pop('partner_address', False) # ignored
|
||||
edi_document['address_invoice_id'] = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
#edi_document['address_contact_id'] = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
|
||||
return partner_id
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@
|
||||
<field name="name">Automated Invoice Notification Mail</field>
|
||||
<field name="email_from">${object.user_id.user_email or object.company_id.email or 'noreply@localhost'}</field>
|
||||
<field name="subject">${object.company_id.name} Invoice (Ref ${object.number or 'n/a' })</field>
|
||||
<field name="email_to">${object.address_invoice_id.email or ''}</field>
|
||||
<field name="email_to">${object.address_contact_id.email or ''}</field>
|
||||
<field name="model_id" ref="account.model_account_invoice"/>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
<field name="body_html"><![CDATA[
|
||||
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
|
||||
|
||||
<p>Hello${object.address_invoice_id.name and ' ' or ''}${object.address_invoice_id.name or ''},</p>
|
||||
<p>Hello${object.address_contact_id.name and ' ' or ''}${object.address_contact_id.name or ''},</p>
|
||||
|
||||
<p>A new invoice is available for ${object.partner_id.name}: </p>
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
</div>
|
||||
]]></field>
|
||||
<field name="body_text"><![CDATA[
|
||||
Hello${object.address_invoice_id.name and ' ' or ''}${object.address_invoice_id.name or ''},
|
||||
Hello${object.address_contact_id.name and ' ' or ''}${object.address_contact_id.name or ''},
|
||||
|
||||
A new invoice is available for ${object.partner_id.name}:
|
||||
| Invoice number: *${object.number}*
|
||||
|
||||
@@ -65,8 +65,6 @@ class account_invoice_report(osv.osv):
|
||||
('cancel','Cancelled')
|
||||
], 'Invoice State', readonly=True),
|
||||
'date_due': fields.date('Due Date', readonly=True),
|
||||
'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True),
|
||||
'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True),
|
||||
'account_id': fields.many2one('account.account', 'Account',readonly=True),
|
||||
'account_line_id': fields.many2one('account.account', 'Account Line',readonly=True),
|
||||
'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True),
|
||||
@@ -103,8 +101,6 @@ class account_invoice_report(osv.osv):
|
||||
ai.state,
|
||||
pt.categ_id,
|
||||
ai.date_due as date_due,
|
||||
ai.address_contact_id as address_contact_id,
|
||||
ai.address_invoice_id as address_invoice_id,
|
||||
ai.account_id as account_id,
|
||||
ail.account_id as account_line_id,
|
||||
ai.partner_bank_id as partner_bank_id,
|
||||
@@ -186,8 +182,6 @@ class account_invoice_report(osv.osv):
|
||||
ai.state,
|
||||
pt.categ_id,
|
||||
ai.date_due,
|
||||
ai.address_contact_id,
|
||||
ai.address_invoice_id,
|
||||
ai.account_id,
|
||||
ail.account_id,
|
||||
ai.partner_bank_id,
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
<field name="period_id" invisible="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="journal_id" invisible="1"/>
|
||||
<field name="address_contact_id" invisible="1"/>
|
||||
<field name="address_invoice_id" invisible="1"/>
|
||||
<field name="partner_bank_id" invisible="1"/>
|
||||
<field name="date_due" invisible="1"/>
|
||||
<field name="account_id" invisible="1"/>
|
||||
|
||||
@@ -162,12 +162,12 @@
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_8">[[ (o.partner_id and o.partner_id.title and o.partner_id.title.name) or '' ]] [[ (o.partner_id and o.partner_id.name) or '' ]]</para>
|
||||
<para style="terp_default_8">[[ display_address(o.address_invoice_id) ]]</para>
|
||||
<para style="terp_default_8">[[ display_address(o.partner_id) ]]</para>
|
||||
<para style="terp_default_8">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="terp_default_8">Tel. : [[ (o.address_invoice_id and o.address_invoice_id.phone) or removeParentNode('para') ]]</para>
|
||||
<para style="terp_default_8">Fax : [[ (o.address_invoice_id and o.address_invoice_id.fax) or removeParentNode('para') ]]</para>
|
||||
<para style="terp_default_8">Tel. : [[ (o.partner_id and o.partner_id.phone) or removeParentNode('para') ]]</para>
|
||||
<para style="terp_default_8">Fax : [[ (o.partner_id and o.partner_id.fax) or removeParentNode('para') ]]</para>
|
||||
<para style="terp_default_8">VAT : [[ (o.partner_id and o.partner_id.vat) or removeParentNode('para') ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -210,7 +210,7 @@
|
||||
<para style="terp_default_Centre_9">[[ o.origin or '' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Centre_9">[[ (o.address_invoice_id and o.address_invoice_id.partner_id and o.address_invoice_id.partner_id.ref) or ' ' ]]</para>
|
||||
<para style="terp_default_Centre_9">[[ (o.partner_id and o.partner_id.ref) or ' ' ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
@@ -38,7 +38,6 @@ class Overdue(report_sxw.rml_parse):
|
||||
def _adr_get(self, partner, type):
|
||||
res = []
|
||||
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
||||
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
||||
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
|
||||
adr_id = addresses and addresses[type] or False
|
||||
result = {
|
||||
@@ -51,7 +50,7 @@ class Overdue(report_sxw.rml_parse):
|
||||
'country_id': False,
|
||||
}
|
||||
if adr_id:
|
||||
result = res_partner_address.read(self.cr, self.uid, [adr_id], context=self.context.copy())
|
||||
result = res_partner.read(self.cr, self.uid, [adr_id], context=self.context.copy())
|
||||
result[0]['country_id'] = result[0]['country_id'] and result[0]['country_id'][1] or False
|
||||
result[0]['state_id'] = result[0]['state_id'] and result[0]['state_id'][1] or False
|
||||
return result
|
||||
@@ -62,7 +61,6 @@ class Overdue(report_sxw.rml_parse):
|
||||
def _tel_get(self,partner):
|
||||
if not partner:
|
||||
return False
|
||||
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
||||
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
||||
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice'])
|
||||
adr_id = addresses and addresses['invoice'] or False
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_currency}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
invoice_line:
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_state}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
invoice_line:
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
!record {model: account.invoice, id: test_invoice_1}:
|
||||
currency_id: base.EUR
|
||||
company_id: base.main_company
|
||||
address_invoice_id: base.res_partner_address_tang
|
||||
partner_id: base.res_partner_asus
|
||||
state: draft
|
||||
type: out_invoice
|
||||
account_id: account.a_recv
|
||||
name: Test invoice 1
|
||||
address_contact_id: base.res_partner_address_tang
|
||||
-
|
||||
In order to test the PDF reports defined on an invoice, we will print an Invoice Report
|
||||
-
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
- I create a draft customer invoice in a period of the demo fiscal year
|
||||
- !record {model: account.invoice, id: invoice_seq_test}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_zen
|
||||
address_invoice_id: base.res_partner_address_zen
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
invoice_line:
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_supplier0}:
|
||||
account_id: account.a_pay
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
check_total: 3000.0
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
name: Precision Test
|
||||
type: out_invoice
|
||||
partner_id: base.res_partner_2
|
||||
address_invoice_id: base.res_partner_address_1
|
||||
account_id: account.a_recv
|
||||
date_invoice: !eval time.strftime('%Y-%m-%d')
|
||||
invoice_line:
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
journal_id: 1
|
||||
partner_id: base.res_partner_agrolait
|
||||
currency_id: base.EUR
|
||||
address_invoice_id: base.res_partner_address_8invoice
|
||||
company_id: 1
|
||||
account_id: account.a_pay
|
||||
date_invoice: !eval "'%s' % (time.strftime('%Y-%m-%d'))"
|
||||
@@ -58,7 +57,7 @@
|
||||
"company_address": {
|
||||
"__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.main_address",
|
||||
"__module": "base",
|
||||
"__model": "res.partner.address",
|
||||
"__model": "res.partner",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:b22acf7a-ddcd-11e0-a4db-701a04e25543.be", "Belgium"],
|
||||
@@ -80,7 +79,7 @@
|
||||
"partner_address": {
|
||||
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",
|
||||
"__module": "base",
|
||||
"__model": "res.partner.address",
|
||||
"__model": "res.partner",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
|
||||
@@ -176,7 +176,7 @@ class account_invoice_refund(osv.osv_memory):
|
||||
invoice = inv_obj.read(cr, uid, [inv.id],
|
||||
['name', 'type', 'number', 'reference',
|
||||
'comment', 'date_due', 'partner_id',
|
||||
'address_contact_id', 'address_invoice_id',
|
||||
'address_contact_id',
|
||||
'partner_insite', 'partner_contact',
|
||||
'partner_ref', 'payment_term', 'account_id',
|
||||
'currency_id', 'invoice_line', 'tax_line',
|
||||
@@ -197,7 +197,7 @@ class account_invoice_refund(osv.osv_memory):
|
||||
'period_id': period,
|
||||
'name': description
|
||||
})
|
||||
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
|
||||
for field in ('address_contact_id', 'partner_id',
|
||||
'account_id', 'currency_id', 'payment_term', 'journal_id'):
|
||||
invoice[field] = invoice[field] and invoice[field][0]
|
||||
inv_id = inv_obj.create(cr, uid, invoice, {})
|
||||
|
||||
@@ -250,8 +250,8 @@ class calendar_attendee(osv.osv):
|
||||
if name == 'cn':
|
||||
if attdata.user_id:
|
||||
result[id][name] = attdata.user_id.name
|
||||
elif attdata.partner_address_id:
|
||||
result[id][name] = attdata.partner_address_id.name or attdata.partner_id.name
|
||||
elif attdata.partner_id:
|
||||
result[id][name] = attdata.partner_id.name or False
|
||||
else:
|
||||
result[id][name] = attdata.email or ''
|
||||
|
||||
@@ -365,9 +365,7 @@ that points to the directory information corresponding to the attendee."),
|
||||
store=True, help="To specify the language for text values in a\
|
||||
property or property parameter."),
|
||||
'user_id': fields.many2one('res.users', 'User'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Contact'),
|
||||
'partner_id': fields.related('partner_address_id', 'partner_id', type='many2one', \
|
||||
relation='res.partner', string='Partner', help="Partner related to contact"),
|
||||
'partner_id': fields.many2one('res.partner', 'Contact'),
|
||||
'email': fields.char('Email', size=124, help="Email of Invited Person"),
|
||||
'event_date': fields.function(_compute_data, string='Event Date', \
|
||||
type="datetime", multi='event_date'),
|
||||
|
||||
@@ -22,10 +22,8 @@
|
||||
<group colspan="4" col="4">
|
||||
<field name="user_id" string="Invited User"/>
|
||||
<newline/>
|
||||
<field name="partner_address_id"
|
||||
string="Contact" />
|
||||
<field name="partner_id"
|
||||
string="Partner" readonly="1" />
|
||||
string="Contact" />
|
||||
</group>
|
||||
<separator string="Event Detail" colspan="4" />
|
||||
<group colspan="4" col="4">
|
||||
@@ -78,7 +76,7 @@
|
||||
<field name="sent_by_uid" string="Invitation From" />
|
||||
<field name="role" string="My Role"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="partner_address_id" invisible="1"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="cutype" string="Invitation type"/>
|
||||
<field name="state" />
|
||||
<field name="rsvp" string="Required to Join"/>
|
||||
@@ -132,7 +130,7 @@
|
||||
<filter string="Responsible" icon="terp-personal" domain="[]"
|
||||
context="{'group_by':'user_id'}" />
|
||||
<filter string="Contact" icon="terp-personal" domain="[]"
|
||||
context="{'group_by':'partner_address_id'}" />
|
||||
context="{'group_by':'partner_id'}" />
|
||||
<separator orientation="vertical" />
|
||||
<filter string="Type" icon="terp-stock_symbol-selection" help="Invitation Type"
|
||||
domain="[]" context="{'group_by':'cutype'}" />
|
||||
|
||||
@@ -41,7 +41,7 @@ class base_calendar_invite_attendee(osv.osv_memory):
|
||||
'invite_id', 'user_id', 'Users'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'email': fields.char('Email', size=124, help="Provide external email address who will receive this invitation."),
|
||||
'contact_ids': fields.many2many('res.partner.address', 'invite_contact_rel',
|
||||
'contact_ids': fields.many2many('res.partner', 'invite_contact_rel',
|
||||
'invite_id', 'contact_id', 'Contacts'),
|
||||
'send_mail': fields.boolean('Send mail?', help='Check this if you want to \
|
||||
send an Email to Invited Person')
|
||||
@@ -112,10 +112,10 @@ send an Email to Invited Person')
|
||||
mail_to.append(datas['email'])
|
||||
|
||||
elif type == 'partner':
|
||||
add_obj = self.pool.get('res.partner.address')
|
||||
add_obj = self.pool.get('res.partner')
|
||||
for contact in add_obj.browse(cr, uid, datas['contact_ids']):
|
||||
res = {
|
||||
'partner_address_id': contact.id,
|
||||
'partner_id': contact.id,
|
||||
'email': contact.email
|
||||
}
|
||||
res.update(ref)
|
||||
@@ -159,8 +159,8 @@ send an Email to Invited Person')
|
||||
|
||||
if not partner_id:
|
||||
return {'value': {'contact_ids': []}}
|
||||
cr.execute('SELECT id FROM res_partner_address \
|
||||
WHERE partner_id=%s', (partner_id,))
|
||||
cr.execute('SELECT id FROM res_partner \
|
||||
WHERE id=%s or parent_id =%s' , (partner_id,partner_id,))
|
||||
contacts = map(lambda x: x[0], cr.fetchall())
|
||||
return {'value': {'contact_ids': contacts}}
|
||||
|
||||
|
||||
+1
-3
@@ -178,7 +178,6 @@ class crm_base(object):
|
||||
date_closed
|
||||
user_id
|
||||
partner_id
|
||||
partner_address_id
|
||||
"""
|
||||
def _get_default_partner_address(self, cr, uid, context=None):
|
||||
"""Gives id of default address for current user
|
||||
@@ -238,7 +237,7 @@ class crm_base(object):
|
||||
"""
|
||||
data = {'value': {'email_from': False, 'phone':False}}
|
||||
if add:
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, add)
|
||||
address = self.pool.get('res.partner').browse(cr, uid, add)
|
||||
data['value'] = {'email_from': address and address.email or False ,
|
||||
'phone': address and address.phone or False}
|
||||
if 'phone' not in self._columns:
|
||||
@@ -254,7 +253,6 @@ class crm_base(object):
|
||||
data={}
|
||||
if part:
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
|
||||
data = {'partner_address_id': addr['contact']}
|
||||
data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
|
||||
return {'value': data}
|
||||
|
||||
|
||||
+45
-43
@@ -40,7 +40,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
_name = "crm.lead"
|
||||
_description = "Lead/Opportunity"
|
||||
_order = "priority,date_action,id desc"
|
||||
_inherit = ['mail.thread','res.partner.address']
|
||||
_inherit = ['mail.thread','res.partner']
|
||||
|
||||
def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None):
|
||||
access_rights_uid = access_rights_uid or uid
|
||||
@@ -170,7 +170,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
domain="['|',('section_id','=',section_id),('section_id','=',False)]", help="From which campaign (seminar, marketing campaign, mass mailing, ...) did this contact come from?"),
|
||||
'channel_id': fields.many2one('crm.case.channel', 'Channel', help="Communication channel (mail, direct, phone, ...)"),
|
||||
'contact_name': fields.char('Contact Name', size=64),
|
||||
'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner that will be created while converting the lead into opportunity', select=1),
|
||||
'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner company that will be created while converting the lead into opportunity', select=1),
|
||||
'optin': fields.boolean('Opt-In', help="If opt-in is checked, this contact has accepted to receive emails."),
|
||||
'optout': fields.boolean('Opt-Out', help="If opt-out is checked, this contact has refused to receive emails or unsubscribed to a campaign."),
|
||||
'type':fields.selection([ ('lead','Lead'), ('opportunity','Opportunity'), ],'Type', help="Type is used to separate Leads and Opportunities"),
|
||||
@@ -194,7 +194,6 @@ class crm_lead(crm_case, osv.osv):
|
||||
|
||||
|
||||
# Only used for type opportunity
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', domain="[('partner_id','=',partner_id)]"),
|
||||
'probability': fields.float('Probability (%)',group_operator="avg"),
|
||||
'planned_revenue': fields.float('Expected Revenue'),
|
||||
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
|
||||
@@ -205,8 +204,8 @@ class crm_lead(crm_case, osv.osv):
|
||||
'title_action': fields.char('Next Action', size=64),
|
||||
'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('section_ids', '=', section_id)]"),
|
||||
'color': fields.integer('Color Index'),
|
||||
'partner_address_name': fields.related('partner_address_id', 'name', type='char', string='Partner Contact Name', readonly=True),
|
||||
'partner_address_email': fields.related('partner_address_id', 'email', type='char', string='Partner Contact Email', readonly=True),
|
||||
'partner_address_name': fields.related('partner_id', 'name', type='char', string='Partner Contact Name', readonly=True),
|
||||
'partner_address_email': fields.related('partner_id', 'email', type='char', string='Partner Contact Email', readonly=True),
|
||||
'company_currency': fields.related('company_id', 'currency_id', 'symbol', type='char', string='Company Currency', readonly=True),
|
||||
'user_email': fields.related('user_id', 'user_email', type='char', string='User Email', readonly=True),
|
||||
'user_login': fields.related('user_id', 'login', type='char', string='User Login', readonly=True),
|
||||
@@ -230,7 +229,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
"""
|
||||
if not add:
|
||||
return {'value': {'email_from': False, 'country_id': False}}
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, add)
|
||||
address = self.pool.get('res.partner').browse(cr, uid, add)
|
||||
return {'value': {'email_from': address.email, 'phone': address.phone, 'country_id': address.country_id.id}}
|
||||
|
||||
def on_change_optin(self, cr, uid, ids, optin):
|
||||
@@ -501,8 +500,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
first_opportunity = opportunities_list[0]
|
||||
tail_opportunities = opportunities_list[1:]
|
||||
|
||||
fields = ['partner_id', 'title', 'name', 'categ_id', 'channel_id', 'city', 'company_id', 'contact_name', 'country_id',
|
||||
'partner_address_id', 'type_id', 'user_id', 'section_id', 'state_id', 'description', 'email', 'fax', 'mobile',
|
||||
fields = ['partner_id', 'title', 'name', 'categ_id', 'channel_id', 'city', 'company_id', 'contact_name', 'country_id', 'type_id', 'user_id', 'section_id', 'state_id', 'description', 'email', 'fax', 'mobile',
|
||||
'partner_name', 'phone', 'probability', 'planned_revenue', 'street', 'street2', 'zip', 'create_date', 'date_action_last',
|
||||
'date_action_next', 'email_from', 'email_cc', 'partner_name']
|
||||
|
||||
@@ -546,7 +544,6 @@ class crm_lead(crm_case, osv.osv):
|
||||
'stage_id': stage_id or False,
|
||||
'date_action': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'date_open': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'partner_address_id': contact_id,
|
||||
}
|
||||
|
||||
def _convert_opportunity_notification(self, cr, uid, lead, context=None):
|
||||
@@ -580,15 +577,42 @@ class crm_lead(crm_case, osv.osv):
|
||||
}, context=context)
|
||||
return True
|
||||
|
||||
def _lead_create_partner(self, cr, uid, lead, context=None):
|
||||
def _lead_create_contact(self, cr, uid, lead, name, is_company, parent_id=False, context=None):
|
||||
partner = self.pool.get('res.partner')
|
||||
partner_id = partner.create(cr, uid, {
|
||||
'name': lead.partner_name or lead.contact_name or lead.name,
|
||||
'user_id': lead.user_id.id,
|
||||
'comment': lead.description,
|
||||
'section_id': lead.section_id.id or False,
|
||||
'address': []
|
||||
})
|
||||
vals = { 'name': name,
|
||||
'user_id': lead.user_id.id,
|
||||
'comment': lead.description,
|
||||
'section_id': lead.section_id.id or False,
|
||||
'parent_id': parent_id,
|
||||
'phone': lead.phone,
|
||||
'mobile': lead.mobile,
|
||||
'email': lead.email_from and to_email(lead.email_from)[0],
|
||||
'fax': lead.fax,
|
||||
'title': lead.title and lead.title.id or False,
|
||||
'function': lead.function,
|
||||
'street': lead.street,
|
||||
'street2': lead.street2,
|
||||
'zip': lead.zip,
|
||||
'city': lead.city,
|
||||
'country_id': lead.country_id and lead.country_id.id or False,
|
||||
'state_id': lead.state_id and lead.state_id.id or False,
|
||||
'is_company': is_company,
|
||||
}
|
||||
|
||||
partner = partner.create(cr, uid,vals, context)
|
||||
return partner
|
||||
|
||||
def _create_lead_partner(self, cr, uid, lead, context=None):
|
||||
partner_id = False
|
||||
if lead.partner_name and lead.contact_name:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.partner_name, 'partner', context=context)
|
||||
self._lead_create_contact(cr, uid, lead, lead.contact_name, 'contact', partner_id, context=context)
|
||||
elif lead.partner_name and not lead.contact_name:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.partner_name, 'partner', context=context)
|
||||
elif not lead.partner_name and lead.contact_name:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.contact_name, 'contact', context=context)
|
||||
else:
|
||||
partner_id = self._lead_create_contact(cr, uid, lead, lead.name, 'contact', context=context)
|
||||
return partner_id
|
||||
|
||||
def _lead_set_partner(self, cr, uid, lead, partner_id, context=None):
|
||||
@@ -597,29 +621,9 @@ class crm_lead(crm_case, osv.osv):
|
||||
if partner_id:
|
||||
res_partner.write(cr, uid, partner_id, {'section_id': lead.section_id.id or False})
|
||||
contact_id = res_partner.address_get(cr, uid, [partner_id])['default']
|
||||
res = lead.write({'partner_id' : partner_id, 'partner_address_id': contact_id}, context=context)
|
||||
|
||||
res = lead.write({'partner_id' : partner_id, }, context=context)
|
||||
return res
|
||||
|
||||
def _lead_create_partner_address(self, cr, uid, lead, partner_id, context=None):
|
||||
address = self.pool.get('res.partner.address')
|
||||
return address.create(cr, uid, {
|
||||
'partner_id': partner_id,
|
||||
'name': lead.contact_name,
|
||||
'phone': lead.phone,
|
||||
'mobile': lead.mobile,
|
||||
'email': lead.email_from and to_email(lead.email_from)[0],
|
||||
'fax': lead.fax,
|
||||
'title': lead.title and lead.title.id or False,
|
||||
'function': lead.function,
|
||||
'street': lead.street,
|
||||
'street2': lead.street2,
|
||||
'zip': lead.zip,
|
||||
'city': lead.city,
|
||||
'country_id': lead.country_id and lead.country_id.id or False,
|
||||
'state_id': lead.state_id and lead.state_id.id or False,
|
||||
})
|
||||
|
||||
def convert_partner(self, cr, uid, ids, action='create', partner_id=False, context=None):
|
||||
"""
|
||||
This function convert partner based on action.
|
||||
@@ -632,8 +636,7 @@ class crm_lead(crm_case, osv.osv):
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
if action == 'create':
|
||||
if not partner_id:
|
||||
partner_id = self._lead_create_partner(cr, uid, lead, context=context)
|
||||
self._lead_create_partner_address(cr, uid, lead, partner_id, context=context)
|
||||
partner_id = self._create_lead_partner(cr, uid, lead, context)
|
||||
self._lead_set_partner(cr, uid, lead, partner_id, context=context)
|
||||
partner_ids[lead.id] = partner_id
|
||||
return partner_ids
|
||||
@@ -694,9 +697,8 @@ class crm_lead(crm_case, osv.osv):
|
||||
'date' : schedule_time,
|
||||
'section_id' : section_id or False,
|
||||
'partner_id': lead.partner_id and lead.partner_id.id or False,
|
||||
'partner_address_id': lead.partner_address_id and lead.partner_address_id.id or False,
|
||||
'partner_phone' : phone or lead.phone or (lead.partner_address_id and lead.partner_address_id.phone or False),
|
||||
'partner_mobile' : lead.partner_address_id and lead.partner_address_id.mobile or False,
|
||||
'partner_phone' : phone or lead.phone or (lead.partner_id and lead.partner_id.phone or False),
|
||||
'partner_mobile' : lead.partner_id and lead.partner_id.mobile or False,
|
||||
'priority': lead.priority,
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
</record>
|
||||
|
||||
<record id="crm_case_mgroperations0" model="crm.lead">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_1"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type_id" ref="crm.type_lead3"/>
|
||||
<field name="partner_id" ref="base.res_partner_9"/>
|
||||
@@ -240,7 +239,6 @@
|
||||
<!-- Demo Opportunities -->
|
||||
<record id="crm_case_construstazunits0" model="crm.lead">
|
||||
<field eval="60" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
@@ -256,7 +254,6 @@
|
||||
<field eval="'Conf call with purchase manager'" name="title_action"/>
|
||||
</record>
|
||||
<record id="crm_case_rdroundfundingunits0" model="crm.lead">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_1"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead2"/>
|
||||
@@ -307,7 +304,6 @@
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead2"/>
|
||||
<field name="partner_id" ref="base.res_partner_accent"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_accent"/>
|
||||
<field eval="'3'" name="priority"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="'open'" name="state"/>
|
||||
@@ -332,7 +328,6 @@
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead2"/>
|
||||
<field name="partner_id" ref="base.res_partner_2"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_9"/>
|
||||
<field eval="'3'" name="priority"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="'open'" name="state"/>
|
||||
@@ -353,7 +348,6 @@
|
||||
</record>
|
||||
<record id="crm_case_mediapoleunits0" model="crm.lead">
|
||||
<field eval="100" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_3"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
@@ -372,7 +366,6 @@
|
||||
</record>
|
||||
<record id="crm_case_abcfuelcounits0" model="crm.lead">
|
||||
<field eval="80" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_marcdubois0"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
@@ -397,7 +390,6 @@
|
||||
</record>
|
||||
<record id="crm_case_dirtminingltdunits25" model="crm.lead">
|
||||
<field eval="30" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_wong"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="partner_id" ref="base.res_partner_maxtor"/>
|
||||
@@ -426,7 +418,6 @@
|
||||
</record>
|
||||
<record id="crm_case_dirtminingltdunits10" model="crm.lead">
|
||||
<field eval="30" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_3000"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="partner_id" ref="base.res_partner_desertic_hispafuentes"/>
|
||||
@@ -450,7 +441,6 @@
|
||||
</record>
|
||||
<record id="crm_case_construstazunits0" model="crm.lead">
|
||||
<field eval="60" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_thymbra"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
@@ -473,7 +463,6 @@
|
||||
</record>
|
||||
<record id="crm_case_ericdubois4" model="crm.lead">
|
||||
<field eval="65" name="probability"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_ericdubois0"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
@@ -496,7 +485,6 @@
|
||||
<field name="country_id" ref="base.be"/>
|
||||
</record>
|
||||
<record id="crm_case_fabiendupont" model="crm.lead">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_fabiendupont0"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
@@ -509,7 +497,6 @@
|
||||
<field eval="'Need more info about the onsite intervention'" name="name"/>
|
||||
</record>
|
||||
<record id="crm_case_shelvehouse" model="crm.lead">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_henrychard1"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="type_id" ref="crm.type_lead1"/>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<notebook colspan="4">
|
||||
<page string="Lead">
|
||||
<group colspan="4" col="2">
|
||||
<field name="partner_name" string="Partner Name" />
|
||||
<field name="partner_name" string="Company Name" />
|
||||
</group>
|
||||
<group colspan="2" col="4">
|
||||
<separator string="Contact" colspan="4" col="4"/>
|
||||
@@ -259,7 +259,6 @@
|
||||
date_start="date_action" color="user_id">
|
||||
<field name="name" />
|
||||
<field name="partner_name" />
|
||||
<field name="partner_address_id" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
@@ -479,10 +478,7 @@
|
||||
string="Create"
|
||||
attrs="{'invisible':[('partner_id','!=',False)]}"/>
|
||||
</group>
|
||||
<field name="partner_address_id"
|
||||
string="Contact"
|
||||
on_change="onchange_partner_address_id(partner_address_id, email_from)"
|
||||
colspan="1" />
|
||||
|
||||
<group col="3" colspan="2">
|
||||
<field name="email_from" string="Email" />
|
||||
<button string="Mail"
|
||||
|
||||
@@ -47,8 +47,6 @@ class crm_meeting(crm_base, osv.osv):
|
||||
# From crm.case
|
||||
'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', states={'done': [('readonly', True)]}),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]", states={'done': [('readonly', True)]}),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', states={'done': [('readonly', True)]}, \
|
||||
select=True, help='Sales team to which Case belongs to.'),
|
||||
'email_from': fields.char('Email', size=128, states={'done': [('readonly', True)]}, help="These people will receive email."),
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
<!--For Meetings-->
|
||||
<record id="crm_case_followuponproposal0" model="crm.meeting">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_wong"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="partner_id" ref="base.res_partner_maxtor"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
@@ -22,7 +21,6 @@
|
||||
</record>
|
||||
|
||||
<record id="crm_case_initialdiscussion0" model="crm.meeting">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_2"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval="7.0" name="duration"/>
|
||||
<field name="partner_id" ref="base.res_partner_10"/>
|
||||
@@ -37,7 +35,6 @@
|
||||
</record>
|
||||
|
||||
<record id="crm_case_discusspricing0" model="crm.meeting">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval="3.0" name="duration"/>
|
||||
<field name="partner_id" ref="base.res_partner_3"/>
|
||||
@@ -52,7 +49,6 @@
|
||||
</record>
|
||||
|
||||
<record id="crm_case_reviewneeds0" model="crm.meeting">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_15"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval="6.0" name="duration"/>
|
||||
<field name="partner_id" ref="base.res_partner_11"/>
|
||||
@@ -66,7 +62,6 @@
|
||||
</record>
|
||||
|
||||
<record id="crm_case_changesindesigning0" model="crm.meeting">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_1"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval="05" name="duration"/>
|
||||
<field name="partner_id" ref="base.res_partner_9"/>
|
||||
@@ -81,7 +76,6 @@
|
||||
</record>
|
||||
|
||||
<record id="crm_case_updatethedata0" model="crm.meeting">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_7"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field name="partner_id" ref="base.res_partner_4"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
|
||||
@@ -60,9 +60,6 @@
|
||||
<separator colspan="2" string="Contacts"/>
|
||||
<field name="partner_id" string="Partner"
|
||||
on_change="onchange_partner_id(partner_id)" />
|
||||
<field name="partner_address_id"
|
||||
string="Contact"
|
||||
on_change="onchange_partner_address_id(partner_address_id, email_from)" />
|
||||
<field name="email_from"/>
|
||||
</group><group col="2" colspan="2">
|
||||
<separator colspan="2" string="Visibility"/>
|
||||
@@ -156,7 +153,6 @@
|
||||
</page>
|
||||
<page string="Other">
|
||||
<field name="user_id"/>
|
||||
<field name="partner_address_id" select="1" />
|
||||
<newline />
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -44,8 +44,6 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
select=True, help='Sales team to which Case belongs to.'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'description': fields.text('Description'),
|
||||
'state': fields.selection([
|
||||
@@ -67,8 +65,6 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
domain="['|',('section_id','=',section_id),('section_id','=',False),\
|
||||
('object_id.model', '=', 'crm.phonecall')]"),
|
||||
'partner_phone': fields.char('Phone', size=32),
|
||||
'partner_contact': fields.related('partner_address_id', 'name', \
|
||||
type="char", string="Contact", size=128),
|
||||
'partner_mobile': fields.char('Mobile', size=32),
|
||||
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
|
||||
'date_closed': fields.datetime('Closed', readonly=True),
|
||||
@@ -95,7 +91,7 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
res = super(crm_phonecall, self).onchange_partner_address_id(cr, uid, ids, add, email)
|
||||
res.setdefault('value', {})
|
||||
if add:
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, add)
|
||||
address = self.pool.get('res.partner').browse(cr, uid, add)
|
||||
res['value']['partner_phone'] = address.phone
|
||||
res['value']['partner_mobile'] = address.mobile
|
||||
return res
|
||||
@@ -153,7 +149,6 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
'date' : schedule_time,
|
||||
'section_id' : section_id or False,
|
||||
'partner_id': call.partner_id and call.partner_id.id or False,
|
||||
'partner_address_id': call.partner_address_id and call.partner_address_id.id or False,
|
||||
'partner_phone' : call.partner_phone,
|
||||
'partner_mobile' : call.partner_mobile,
|
||||
'priority': call.priority,
|
||||
@@ -180,9 +175,9 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
return self.write(cr, uid, ids, {'partner_id' : partner_id}, context=context)
|
||||
|
||||
def _call_create_partner_address(self, cr, uid, phonecall, partner_id, context=None):
|
||||
address = self.pool.get('res.partner.address')
|
||||
address = self.pool.get('res.partner')
|
||||
return address.create(cr, uid, {
|
||||
'partner_id': partner_id,
|
||||
'parent_id': partner_id,
|
||||
'name': phonecall.name,
|
||||
'phone': phonecall.partner_phone,
|
||||
})
|
||||
@@ -227,7 +222,6 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
|
||||
def convert_opportunity(self, cr, uid, ids, opportunity_summary=False, partner_id=False, planned_revenue=0.0, probability=0.0, context=None):
|
||||
partner = self.pool.get('res.partner')
|
||||
address = self.pool.get('res.partner.address')
|
||||
opportunity = self.pool.get('crm.lead')
|
||||
opportunity_dict = {}
|
||||
default_contact = False
|
||||
@@ -237,14 +231,12 @@ class crm_phonecall(crm_base, osv.osv):
|
||||
if partner_id:
|
||||
address_id = partner.address_get(cr, uid, [partner_id])['default']
|
||||
if address_id:
|
||||
default_contact = address.browse(cr, uid, address_id, context=context)
|
||||
default_contact = partner.browse(cr, uid, address_id, context=context)
|
||||
opportunity_id = opportunity.create(cr, uid, {
|
||||
'name': opportunity_summary or call.name,
|
||||
'planned_revenue': planned_revenue,
|
||||
'probability': probability,
|
||||
'partner_id': partner_id or False,
|
||||
'partner_address_id': default_contact and default_contact.id,
|
||||
'phone': default_contact and default_contact.phone,
|
||||
'mobile': default_contact and default_contact.mobile,
|
||||
'section_id': call.section_id and call.section_id.id or False,
|
||||
'description': call.description or False,
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
((((((((((( Demo Cases )))))))))))
|
||||
-->
|
||||
<record id="crm_case_phone01" model="crm.phonecall">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_15"/>
|
||||
<field eval="time.strftime('%Y-%m-04 10:45:36')" name="date"/>
|
||||
<field name="partner_id" ref="base.res_partner_11"/>
|
||||
<field eval=""3"" name="priority"/>
|
||||
@@ -21,7 +20,6 @@
|
||||
<field eval=""done"" name="state"/>
|
||||
</record>
|
||||
<record id="crm_case_phone02" model="crm.phonecall">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_6"/>
|
||||
<field eval="time.strftime('%Y-%m-11 11:19:25')" name="date"/>
|
||||
<field name="partner_id" ref="base.res_partner_6"/>
|
||||
<field eval=""4"" name="priority"/>
|
||||
@@ -37,7 +35,6 @@
|
||||
<field eval=""done"" name="state"/>
|
||||
</record>
|
||||
<record id="crm_case_phone03" model="crm.phonecall">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_2"/>
|
||||
<field eval="time.strftime('%Y-%m-15 17:44:12')" name="date"/>
|
||||
<field name="partner_id" ref="base.res_partner_10"/>
|
||||
<field eval=""2"" name="priority"/>
|
||||
@@ -68,7 +65,6 @@
|
||||
<field eval="3.45" name="duration"/>
|
||||
</record>
|
||||
<record id="crm_case_phone05" model="crm.phonecall">
|
||||
<field name="partner_address_id" ref="base.res_partner_address_10"/>
|
||||
<field eval="time.strftime('%Y-%m-28 16:20:43')" name="date"/>
|
||||
<field name="partner_id" ref="base.res_partner_5"/>
|
||||
<field eval=""3"" name="priority"/>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="partner_contact"/>
|
||||
<field name="partner_phone"/>
|
||||
<field name="user_id"/>
|
||||
<field name="categ_id" invisible="1"/>
|
||||
@@ -91,8 +90,6 @@
|
||||
attrs="{'invisible':[('partner_id','!=',False)]}"
|
||||
groups="base.group_partner_manager"/>
|
||||
<newline/>
|
||||
<field name="partner_address_id"
|
||||
on_change="onchange_partner_address_id(partner_address_id)" />
|
||||
<newline/>
|
||||
<field name="partner_mobile" />
|
||||
</group>
|
||||
@@ -140,9 +137,7 @@
|
||||
<field name="partner_id"
|
||||
on_change="onchange_partner_id(partner_id)"
|
||||
string="Partner" />
|
||||
<field name="partner_address_id"
|
||||
on_change="onchange_partner_address_id(partner_address_id)"
|
||||
invisible="1"/>
|
||||
|
||||
<field name="partner_phone"
|
||||
invisible="1"/>
|
||||
<field name="user_id" groups="base.group_extended"/>
|
||||
|
||||
@@ -64,7 +64,6 @@ class res_partner(osv.osv):
|
||||
'planned_revenue' : planned_revenue,
|
||||
'probability' : probability,
|
||||
'partner_id' : partner_id,
|
||||
'partner_address_id' : address,
|
||||
'categ_id' : categ_ids and categ_ids[0] or '',
|
||||
'state' :'draft',
|
||||
'type': 'opportunity'
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<field name="inherit_id" ref="base.view_partner_tree"/>
|
||||
<field eval="18" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="country" position="after">
|
||||
<field name="phone" position="after">
|
||||
<field name="section_id" completion="1" widget="selection"
|
||||
groups="base.group_extended"/>
|
||||
</field>
|
||||
|
||||
@@ -67,8 +67,6 @@ class crm_lead2opportunity_partner(osv.osv_memory):
|
||||
ids = lead_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', '=', 'opportunity'), '!', ('state', 'in', ['done', 'cancel'])])
|
||||
if ids:
|
||||
opportunities.append(ids[0])
|
||||
|
||||
|
||||
if not partner_id:
|
||||
label = False
|
||||
opp_ids = []
|
||||
|
||||
@@ -55,9 +55,9 @@ class crm_opportunity2phonecall(osv.osv_memory):
|
||||
if 'note' in fields:
|
||||
res.update({'note': opp.description})
|
||||
if 'contact_name' in fields:
|
||||
res.update({'contact_name': opp.partner_address_id and opp.partner_address_id.name or False})
|
||||
res.update({'contact_name': opp.partner_id and opp.partner_id.name or False})
|
||||
if 'phone' in fields:
|
||||
res.update({'phone': opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False)})
|
||||
res.update({'phone': opp.phone or (opp.partner_id and opp.partner_id.phone or False)})
|
||||
return res
|
||||
|
||||
def action_schedule(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -38,17 +38,16 @@ class crm_phonecall2partner(osv.osv_memory):
|
||||
|
||||
phonecall_obj = self.pool.get('crm.phonecall')
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
contact_obj = self.pool.get('res.partner.address')
|
||||
rec_ids = context and context.get('active_ids', [])
|
||||
value = {}
|
||||
|
||||
partner_id = False
|
||||
for phonecall in phonecall_obj.browse(cr, uid, rec_ids, context=context):
|
||||
partner_ids = partner_obj.search(cr, uid, [('name', '=', phonecall.name or phonecall.name)])
|
||||
if not partner_ids and phonecall.email_from:
|
||||
address_ids = contact_obj.search(cr, uid, ['|', ('phone', '=', phonecall.partner_phone), ('mobile','=',phonecall.partner_mobile)])
|
||||
address_ids = partner_obj.search(cr, uid, ['|', ('phone', '=', phonecall.partner_phone), ('mobile','=',phonecall.partner_mobile)])
|
||||
if address_ids:
|
||||
addresses = contact_obj.browse(cr, uid, address_ids)
|
||||
partner_ids = addresses and [addresses[0].partner_id.id] or False
|
||||
addresses = partner_ids.browse(cr, uid, address_ids)
|
||||
partner_ids = addresses and [addresses[0].parent_id.id] or False
|
||||
|
||||
partner_id = partner_ids and partner_ids[0] or False
|
||||
return partner_id
|
||||
|
||||
@@ -311,9 +311,6 @@ class document_file(osv.osv):
|
||||
elif 'partner_id' in obj_model._columns and obj_model._columns['partner_id']._obj == 'res.partner':
|
||||
bro = obj_model.browse(cr, uid, res_id, context=context)
|
||||
return bro.partner_id.id
|
||||
elif 'address_id' in obj_model._columns and obj_model._columns['address_id']._obj == 'res.partner.address':
|
||||
bro = obj_model.browse(cr, uid, res_id, context=context)
|
||||
return bro.address_id.partner_id.id
|
||||
return False
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -37,13 +37,13 @@ class res_company(osv.osv):
|
||||
an empty dict if no address can be found
|
||||
"""
|
||||
res_partner = self.pool.get('res.partner')
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
# res_partner_address = self.pool.get('res.partner.address')
|
||||
addresses = res_partner.address_get(cr, uid, [company.partner_id.id], ['default', 'contact', 'invoice'])
|
||||
addr_id = addresses['invoice'] or addresses['contact'] or addresses['default']
|
||||
result = {}
|
||||
if addr_id:
|
||||
address = res_partner_address.browse(cr, uid, addr_id, context=context)
|
||||
result = res_partner_address.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=context)[0]
|
||||
address = res_partner.browse(cr, uid, addr_id, context=context)
|
||||
result = res_partner.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=context)[0]
|
||||
if company.logo:
|
||||
result['logo'] = company.logo # already base64-encoded
|
||||
if company.paypal_account:
|
||||
@@ -52,7 +52,7 @@ class res_company(osv.osv):
|
||||
res_partner_bank = self.pool.get('res.partner.bank')
|
||||
bank_ids = res_partner_bank.search(cr, uid, [('company_id','=',company.id),('footer','=',True)], context=context)
|
||||
if bank_ids:
|
||||
result['bank_ids'] = res_partner_address.edi_m2m(cr, uid,
|
||||
result['bank_ids'] = res_partner.edi_m2m(cr, uid,
|
||||
res_partner_bank.browse(cr, uid, bank_ids, context=context),
|
||||
context=context)
|
||||
return result
|
||||
|
||||
@@ -44,7 +44,18 @@ RES_PARTNER_EDI_STRUCT = {
|
||||
'ref': True,
|
||||
'lang': True,
|
||||
'website': True,
|
||||
'address': RES_PARTNER_ADDRESS_EDI_STRUCT
|
||||
# 'address': RES_PARTNER_ADDRESS_EDI_STRUCT
|
||||
# 'name': True,
|
||||
'email': True,
|
||||
'street': True,
|
||||
'street2': True,
|
||||
'zip': True,
|
||||
'city': True,
|
||||
'country_id': True,
|
||||
'state_id': True,
|
||||
'phone': True,
|
||||
'fax': True,
|
||||
'mobile': True,
|
||||
}
|
||||
|
||||
class res_partner(osv.osv, EDIMixin):
|
||||
@@ -55,9 +66,6 @@ class res_partner(osv.osv, EDIMixin):
|
||||
edi_struct or dict(RES_PARTNER_EDI_STRUCT),
|
||||
context=context)
|
||||
|
||||
class res_partner_address(osv.osv, EDIMixin):
|
||||
_inherit = "res.partner.address"
|
||||
|
||||
def _get_bank_type(self, cr, uid, context=None):
|
||||
# first option: the "normal" bank type, installed by default
|
||||
res_partner_bank_type = self.pool.get('res.partner.bank.type')
|
||||
@@ -65,7 +73,6 @@ class res_partner_address(osv.osv, EDIMixin):
|
||||
return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'bank_normal', context=context).code
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# second option: create a new custom type for EDI or use it if already created, as IBAN type is
|
||||
# not always appropriate: we need a free-form bank type for max flexibility (users can correct
|
||||
# data manually after import)
|
||||
@@ -78,19 +85,14 @@ class res_partner_address(osv.osv, EDIMixin):
|
||||
'code': label})
|
||||
return code
|
||||
|
||||
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
return super(res_partner_address,self).edi_export(cr, uid, records,
|
||||
edi_struct or dict(RES_PARTNER_ADDRESS_EDI_STRUCT),
|
||||
context=context)
|
||||
|
||||
def edi_import(self, cr, uid, edi_document, context=None):
|
||||
# handle bank info, if any
|
||||
edi_bank_ids = edi_document.pop('bank_ids', None)
|
||||
address_id = super(res_partner_address,self).edi_import(cr, uid, edi_document, context=context)
|
||||
contact_id = super(res_partner,self).edi_import(cr, uid, edi_document, context=context)
|
||||
if edi_bank_ids:
|
||||
address = self.browse(cr, uid, address_id, context=context)
|
||||
contacts = self.browse(cr, uid, contact_id, context=context)
|
||||
import_ctx = dict((context or {}),
|
||||
default_partner_id=address.partner_id.id,
|
||||
default_partner_id=contacts.partner_id.id,
|
||||
default_state=self._get_bank_type(cr, uid, context))
|
||||
for ext_bank_id, bank_name in edi_bank_ids:
|
||||
try:
|
||||
@@ -101,5 +103,7 @@ class res_partner_address(osv.osv, EDIMixin):
|
||||
logging.getLogger('edi.res_partner').warning('Failed to import bank account using'
|
||||
'bank type: %s, ignoring', import_ctx['default_state'],
|
||||
exc_info=True)
|
||||
return address_id
|
||||
return contact_id
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user