[IMP] account : remove invoice address

bzr revid: kjo@tinyerp.com-20120305064845-aezglwmj86fi2ndc
This commit is contained in:
Kuldeep Joshi (OpenERP) 2012-03-05 12:18:45 +05:30
parent 88c25488a5
commit fd384fe645
20 changed files with 42 additions and 63 deletions

View File

@ -1963,8 +1963,8 @@ class account_tax(osv.osv):
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
_defaults = { _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': '''# 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.address object or False\n# product: product.product object or False\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', 'applicable_type': 'true',
'type': 'percent', 'type': 'percent',
'amount': 0, '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): def _applicable(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
res = [] res = []
obj_partener_address = self.pool.get('res.partner.address') obj_partener_address = self.pool.get('res.partner')
for tax in taxes: for tax in taxes:
if tax.applicable_type=='code': if tax.applicable_type=='code':
localdict = {'price_unit':price_unit, 'address':obj_partener_address.browse(cr, uid, address_id), 'product':product, 'partner':partner} 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) taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
res = [] res = []
cur_price_unit=price_unit 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: for tax in taxes:
# we compute the amount for the current tax object and append it to the result # we compute the amount for the current tax object and append it to the result
data = {'id':tax.id, 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): 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) 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 = [] res = []
taxes.reverse() taxes.reverse()
cur_price_unit = price_unit 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] return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
_defaults = { _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': 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.address object or False\n# product: product.product object or False\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', 'applicable_type': 'true',
'type': 'percent', 'type': 'percent',
'amount': 0, 'amount': 0,

View File

@ -216,8 +216,7 @@ class account_invoice(osv.osv):
help="If you use payment terms, the due date will be computed automatically at the generation "\ 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."), "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)]}), '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_contact_id': fields.many2one('res.partner', '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)]}, '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 "\ 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. "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "\
@ -443,7 +442,6 @@ class account_invoice(osv.osv):
result = {'value': { result = {'value': {
'address_contact_id': contact_addr_id, 'address_contact_id': contact_addr_id,
'address_invoice_id': invoice_addr_id,
'account_id': acc_id, 'account_id': acc_id,
'payment_term': partner_payment_term, 'payment_term': partner_payment_term,
'fiscal_position': fiscal_position 'fiscal_position': fiscal_position
@ -1092,7 +1090,7 @@ class account_invoice(osv.osv):
return map(lambda x: (0,0,x), lines) return map(lambda x: (0,0,x), lines)
def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None): 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', 'address_contact_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_line = self.pool.get('account.invoice.line')
obj_invoice_tax = self.pool.get('account.invoice.tax') obj_invoice_tax = self.pool.get('account.invoice.tax')
obj_journal = self.pool.get('account.journal') obj_journal = self.pool.get('account.journal')
@ -1140,7 +1138,7 @@ class account_invoice(osv.osv):
'name': description, 'name': description,
}) })
# take the id part of the tuple returned for many2one fields # 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 ('address_contact_id', 'partner_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'): 'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0] invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice # create the new invoice
@ -1257,7 +1255,7 @@ class account_invoice_line(osv.osv):
cur_obj = self.pool.get('res.currency') cur_obj = self.pool.get('res.currency')
for line in self.browse(cr, uid, ids): for line in self.browse(cr, uid, ids):
price = line.price_unit * (1-(line.discount or 0.0)/100.0) 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'] res[line.id] = taxes['total']
if line.invoice_id: if line.invoice_id:
cur = line.invoice_id.currency_id cur = line.invoice_id.currency_id
@ -1277,7 +1275,7 @@ class account_invoice_line(osv.osv):
taxes = l[2].get('invoice_line_tax_id') taxes = l[2].get('invoice_line_tax_id')
if len(taxes[0]) >= 3 and taxes[0][2]: if len(taxes[0]) >= 3 and taxes[0][2]:
taxes = tax_obj.browse(cr, uid, list(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'] t = t - tax['amount']
return t return t
return 0 return 0
@ -1322,7 +1320,7 @@ class account_invoice_line(osv.osv):
res['arch'] = etree.tostring(doc) res['arch'] = etree.tostring(doc)
return res 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: if context is None:
context = {} context = {}
company_id = company_id if company_id != None else context.get('company_id',False) company_id = company_id if company_id != None else context.get('company_id',False)
@ -1404,7 +1402,7 @@ class account_invoice_line(osv.osv):
context = dict(context) context = dict(context)
context.update({'company_id': company_id}) context.update({'company_id': company_id})
warning = {} 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']: if 'uos_id' in res['value']:
del res['value']['uos_id'] del res['value']['uos_id']
if not uom: if not uom:
@ -1437,7 +1435,7 @@ class account_invoice_line(osv.osv):
tax_code_found= False tax_code_found= False
for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, 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.price_unit * (1.0 - (line['discount'] or 0.0) / 100.0)),
line.quantity, inv.address_invoice_id.id, line.product_id, line.quantity, inv.address_contact_id.id, line.product_id,
inv.partner_id)['taxes']: inv.partner_id)['taxes']:
if inv.type in ('out_invoice', 'in_invoice'): if inv.type in ('out_invoice', 'in_invoice'):
@ -1572,7 +1570,7 @@ class account_invoice_tax(osv.osv):
company_currency = inv.company_id.currency_id.id company_currency = inv.company_id.currency_id.id
for line in inv.invoice_line: 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, inv.address_contact_id.id, line.product_id, inv.partner_id)['taxes']:
tax['price_unit'] = cur_obj.round(cr, uid, cur, tax['price_unit']) tax['price_unit'] = cur_obj.round(cr, uid, cur, tax['price_unit'])
val={} val={}
val['invoice_id'] = inv.id val['invoice_id'] = inv.id

View File

@ -51,12 +51,12 @@
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Invoice Line"> <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"/> <field colspan="2" name="name"/>
<label string="Quantity :" align="1.0"/> <label string="Quantity :" align="1.0"/>
<group colspan="1" col="2"> <group colspan="1" col="2">
<field name="quantity" nolabel="1"/> <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> </group>
<field name="price_unit"/> <field name="price_unit"/>
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/> <field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', '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"/> <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"/> <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/> <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 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 domain="[('partner_id','=',partner_id)]" name="address_invoice_id" context="{'default_partner_id': partner_id}" options='{"quick_create": false}'/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/> <field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/> <newline/>
<field name="date_invoice"/> <field name="date_invoice"/>
@ -168,9 +167,9 @@
<field name="reference_type" nolabel="1" size="0"/> <field name="reference_type" nolabel="1" size="0"/>
<field name="reference" nolabel="1"/> <field name="reference" nolabel="1"/>
<field name="date_due"/> <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="{'address_contact_id': address_contact_id, '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"> <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', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(product_id,parent.partner_id,parent.type,parent.fiscal_position,account_id)"/> <field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', '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 name="invoice_line_tax_id" view_mode="2" context="{'type':parent.type}" domain="[('parent_id','=',False)]"/>
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/> <field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
@ -262,8 +261,7 @@
<field name="currency_id" width="50"/> <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"/> <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/> <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 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 domain="[('partner_id','=',partner_id)]" name="address_invoice_id" context="{'default_partner_id': partner_id}" options='{"quick_create": false}'/>
<field name="fiscal_position" groups="base.group_extended" widget="selection" options='{"quick_create": false}'/> <field name="fiscal_position" groups="base.group_extended" widget="selection" options='{"quick_create": false}'/>
<newline/> <newline/>
<field name="date_invoice"/> <field name="date_invoice"/>

View File

@ -7,8 +7,8 @@
wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo')) wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo'))
part = self.pool.get('res.partner').browse(cr, uid, ref('base.main_partner')) 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 we know the country and the wizard has not yet been executed, we do it
if (part.country.id) and (wiz.state=='open'): if (part.country_id.id) and (wiz.state=='open'):
mod = 'l10n_'+part.country.code.lower() mod = 'l10n_'+part.country_id.co7de.lower()
ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context) ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context)
if ids: if ids:
wizards.write(cr, uid, [ref('account.account_configuration_installer_todo')], { wizards.write(cr, uid, [ref('account.account_configuration_installer_todo')], {

View File

@ -5,7 +5,6 @@
<record id="test_invoice_1" model="account.invoice"> <record id="test_invoice_1" model="account.invoice">
<field name="currency_id" ref="base.EUR"/> <field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/> <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="partner_id" ref="base.res_partner_asus"/>
<field name="journal_id" ref="account.sales_journal"/> <field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field> <field name="state">draft</field>

View File

@ -6,9 +6,7 @@
<field name="payment_term" ref="account.account_payment_term"/> <field name="payment_term" ref="account.account_payment_term"/>
<field name="journal_id" ref="account.expenses_journal"/> <field name="journal_id" ref="account.expenses_journal"/>
<field name="currency_id" ref="base.EUR"/> <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="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="reference_type">none</field>
<field name="company_id" ref="base.main_company"/> <field name="company_id" ref="base.main_company"/>
<field name="state">draft</field> <field name="state">draft</field>

View File

@ -75,7 +75,7 @@ class account_invoice(osv.osv, EDIMixin):
"""Exports a supplier or customer invoice""" """Exports a supplier or customer invoice"""
edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT) edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT)
res_company = self.pool.get('res.company') 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 = [] edi_doc_list = []
for invoice in records: for invoice in records:
# generate the main report # generate the main report
@ -84,7 +84,7 @@ class account_invoice(osv.osv, EDIMixin):
edi_doc.update({ edi_doc.update({
'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context), 'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context),
'company_paypal_account': invoice.company_id.paypal_account, '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.address_contact_id], context=context)[0],
'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_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, '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 # the desired company among the user's allowed companies
self._edi_requires_attributes(('company_id','company_address','type'), edi_document) 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') res_partner = self.pool.get('res.partner')
# imported company = new partner # imported company = new partner
@ -144,13 +143,13 @@ class account_invoice(osv.osv, EDIMixin):
address_info = edi_document.pop('company_address') address_info = edi_document.pop('company_address')
address_info['partner_id'] = (src_company_id, src_company_name) address_info['partner_id'] = (src_company_id, src_company_name)
address_info['type'] = 'invoice' 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 # 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['partner_id'] = (src_company_id, src_company_name)
edi_document.pop('partner_address', False) # ignored 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 return partner_id

View File

@ -40,13 +40,13 @@
<field name="name">Automated Invoice Notification Mail</field> <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="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="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="model_id" ref="account.model_account_invoice"/>
<field name="auto_delete" eval="True"/> <field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[ <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); "> <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> <p>A new invoice is available for ${object.partner_id.name}: </p>
@ -124,7 +124,7 @@
</div> </div>
]]></field> ]]></field>
<field name="body_text"><![CDATA[ <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}: A new invoice is available for ${object.partner_id.name}:
| Invoice number: *${object.number}* | Invoice number: *${object.number}*

View File

@ -65,8 +65,7 @@ class account_invoice_report(osv.osv):
('cancel','Cancelled') ('cancel','Cancelled')
], 'Invoice State', readonly=True), ], 'Invoice State', readonly=True),
'date_due': fields.date('Due Date', readonly=True), 'date_due': fields.date('Due Date', readonly=True),
'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True), 'address_contact_id': fields.many2one('res.partner', '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_id': fields.many2one('account.account', 'Account',readonly=True),
'account_line_id': fields.many2one('account.account', 'Account Line',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), 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True),
@ -104,7 +103,6 @@ class account_invoice_report(osv.osv):
pt.categ_id, pt.categ_id,
ai.date_due as date_due, ai.date_due as date_due,
ai.address_contact_id as address_contact_id, ai.address_contact_id as address_contact_id,
ai.address_invoice_id as address_invoice_id,
ai.account_id as account_id, ai.account_id as account_id,
ail.account_id as account_line_id, ail.account_id as account_line_id,
ai.partner_bank_id as partner_bank_id, ai.partner_bank_id as partner_bank_id,
@ -187,7 +185,6 @@ class account_invoice_report(osv.osv):
pt.categ_id, pt.categ_id,
ai.date_due, ai.date_due,
ai.address_contact_id, ai.address_contact_id,
ai.address_invoice_id,
ai.account_id, ai.account_id,
ail.account_id, ail.account_id,
ai.partner_bank_id, ai.partner_bank_id,

View File

@ -23,7 +23,6 @@
<field name="currency_id" invisible="1"/> <field name="currency_id" invisible="1"/>
<field name="journal_id" invisible="1"/> <field name="journal_id" invisible="1"/>
<field name="address_contact_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="partner_bank_id" invisible="1"/>
<field name="date_due" invisible="1"/> <field name="date_due" invisible="1"/>
<field name="account_id" invisible="1"/> <field name="account_id" invisible="1"/>

View File

@ -162,12 +162,12 @@
</td> </td>
<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">[[ (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.address_contact_id) ]]</para>
<para style="terp_default_8"> <para style="terp_default_8">
<font color="white"> </font> <font color="white"> </font>
</para> </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">Tel. : [[ (o.address_contact_id and o.address_contact_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">Fax : [[ (o.address_contact_id and o.address_contact_id.fax) or removeParentNode('para') ]]</para>
<para style="terp_default_8">VAT : [[ (o.partner_id and o.partner_id.vat) or removeParentNode('para') ]]</para> <para style="terp_default_8">VAT : [[ (o.partner_id and o.partner_id.vat) or removeParentNode('para') ]]</para>
</td> </td>
</tr> </tr>
@ -210,7 +210,7 @@
<para style="terp_default_Centre_9">[[ o.origin or '' ]]</para> <para style="terp_default_Centre_9">[[ o.origin or '' ]]</para>
</td> </td>
<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.address_contact_id.partner_id and o.address_contact_id.partner_id.ref) or ' ' ]]</para>
</td> </td>
</tr> </tr>
</blockTable> </blockTable>

View File

@ -38,7 +38,6 @@ class Overdue(report_sxw.rml_parse):
def _adr_get(self, partner, type): def _adr_get(self, partner, type):
res = [] res = []
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner') 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]) addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
adr_id = addresses and addresses[type] or False adr_id = addresses and addresses[type] or False
result = { result = {
@ -51,7 +50,7 @@ class Overdue(report_sxw.rml_parse):
'country_id': False, 'country_id': False,
} }
if adr_id: 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]['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 result[0]['state_id'] = result[0]['state_id'] and result[0]['state_id'][1] or False
return result return result
@ -62,7 +61,6 @@ class Overdue(report_sxw.rml_parse):
def _tel_get(self,partner): def _tel_get(self,partner):
if not partner: if not partner:
return False 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') res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice']) addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice'])
adr_id = addresses and addresses['invoice'] or False adr_id = addresses and addresses['invoice'] or False

View File

@ -4,7 +4,6 @@
!record {model: account.invoice, id: account_invoice_currency}: !record {model: account.invoice, id: account_invoice_currency}:
account_id: account.a_recv account_id: account.a_recv
address_contact_id: base.res_partner_address_3000 address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
company_id: base.main_company company_id: base.main_company
currency_id: base.EUR currency_id: base.EUR
invoice_line: invoice_line:

View File

@ -4,7 +4,6 @@
!record {model: account.invoice, id: account_invoice_state}: !record {model: account.invoice, id: account_invoice_state}:
account_id: account.a_recv account_id: account.a_recv
address_contact_id: base.res_partner_address_3000 address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
company_id: base.main_company company_id: base.main_company
currency_id: base.EUR currency_id: base.EUR
invoice_line: invoice_line:

View File

@ -4,7 +4,6 @@
!record {model: account.invoice, id: test_invoice_1}: !record {model: account.invoice, id: test_invoice_1}:
currency_id: base.EUR currency_id: base.EUR
company_id: base.main_company company_id: base.main_company
address_invoice_id: base.res_partner_address_tang
partner_id: base.res_partner_asus partner_id: base.res_partner_asus
state: draft state: draft
type: out_invoice type: out_invoice

View File

@ -17,7 +17,6 @@
- !record {model: account.invoice, id: invoice_seq_test}: - !record {model: account.invoice, id: invoice_seq_test}:
account_id: account.a_recv account_id: account.a_recv
address_contact_id: base.res_partner_address_zen address_contact_id: base.res_partner_address_zen
address_invoice_id: base.res_partner_address_zen
company_id: base.main_company company_id: base.main_company
currency_id: base.EUR currency_id: base.EUR
invoice_line: invoice_line:

View File

@ -24,7 +24,6 @@
!record {model: account.invoice, id: account_invoice_supplier0}: !record {model: account.invoice, id: account_invoice_supplier0}:
account_id: account.a_pay account_id: account.a_pay
address_contact_id: base.res_partner_address_3000 address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
check_total: 3000.0 check_total: 3000.0
company_id: base.main_company company_id: base.main_company
currency_id: base.EUR currency_id: base.EUR

View File

@ -21,7 +21,6 @@
name: Precision Test name: Precision Test
type: out_invoice type: out_invoice
partner_id: base.res_partner_2 partner_id: base.res_partner_2
address_invoice_id: base.res_partner_address_1
account_id: account.a_recv account_id: account.a_recv
date_invoice: !eval time.strftime('%Y-%m-%d') date_invoice: !eval time.strftime('%Y-%m-%d')
invoice_line: invoice_line:

View File

@ -7,7 +7,6 @@
journal_id: 1 journal_id: 1
partner_id: base.res_partner_agrolait partner_id: base.res_partner_agrolait
currency_id: base.EUR currency_id: base.EUR
address_invoice_id: base.res_partner_address_8invoice
company_id: 1 company_id: 1
account_id: account.a_pay account_id: account.a_pay
date_invoice: !eval "'%s' % (time.strftime('%Y-%m-%d'))" date_invoice: !eval "'%s' % (time.strftime('%Y-%m-%d'))"
@ -58,7 +57,7 @@
"company_address": { "company_address": {
"__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.main_address", "__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.main_address",
"__module": "base", "__module": "base",
"__model": "res.partner.address", "__model": "res.partner",
"city": "Gerompont", "city": "Gerompont",
"zip": "1367", "zip": "1367",
"country_id": ["base:b22acf7a-ddcd-11e0-a4db-701a04e25543.be", "Belgium"], "country_id": ["base:b22acf7a-ddcd-11e0-a4db-701a04e25543.be", "Belgium"],
@ -80,7 +79,7 @@
"partner_address": { "partner_address": {
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh", "__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",
"__module": "base", "__module": "base",
"__model": "res.partner.address", "__model": "res.partner",
"phone": "(+32).81.81.37.00", "phone": "(+32).81.81.37.00",
"street": "Chaussee de Namur 40", "street": "Chaussee de Namur 40",
"city": "Gerompont", "city": "Gerompont",

View File

@ -176,7 +176,7 @@ class account_invoice_refund(osv.osv_memory):
invoice = inv_obj.read(cr, uid, [inv.id], invoice = inv_obj.read(cr, uid, [inv.id],
['name', 'type', 'number', 'reference', ['name', 'type', 'number', 'reference',
'comment', 'date_due', 'partner_id', 'comment', 'date_due', 'partner_id',
'address_contact_id', 'address_invoice_id', 'address_contact_id',
'partner_insite', 'partner_contact', 'partner_insite', 'partner_contact',
'partner_ref', 'payment_term', 'account_id', 'partner_ref', 'payment_term', 'account_id',
'currency_id', 'invoice_line', 'tax_line', 'currency_id', 'invoice_line', 'tax_line',
@ -197,7 +197,7 @@ class account_invoice_refund(osv.osv_memory):
'period_id': period, 'period_id': period,
'name': description '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'): 'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0] invoice[field] = invoice[field] and invoice[field][0]
inv_id = inv_obj.create(cr, uid, invoice, {}) inv_id = inv_obj.create(cr, uid, invoice, {})