[MERGE] Fix error edi,account,sale module
bzr revid: kjo@tinyerp.com-20120322090929-7e42bolppvuo9dzi
This commit is contained in:
@@ -126,30 +126,30 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
self._edi_requires_attributes(('company_id','company_address','type'), edi_document)
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company = new partner
|
||||
src_company_id, src_company_name = edi_document.pop('company_id')
|
||||
partner_id = self.edi_import_relation(cr, uid, 'res.partner', src_company_name,
|
||||
src_company_id, context=context)
|
||||
|
||||
invoice_type = edi_document['type']
|
||||
partner_value = {}
|
||||
if invoice_type in ('out_invoice', 'out_refund'):
|
||||
partner_value.update({'customer': True})
|
||||
if invoice_type in ('in_invoice', 'in_refund'):
|
||||
partner_value.update({'supplier': True})
|
||||
res_partner.write(cr, uid, [partner_id], partner_value, context=context)
|
||||
|
||||
# imported company_address = new partner address
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['parent_id'] = (src_company_id, src_company_name)
|
||||
if 'name' not in address_info:
|
||||
address_info['name'] = src_company_name
|
||||
address_info['type'] = 'invoice'
|
||||
address_info.update(partner_value)
|
||||
address_id = res_partner.edi_import(cr, uid, address_info, context=context)
|
||||
|
||||
# modify edi_document to refer to new partner
|
||||
partner_address = res_partner.browse(cr, uid, address_id, context=context)
|
||||
edi_document['partner_id'] = (src_company_id, src_company_name)
|
||||
address_edi_m2o = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
edi_document['partner_id'] = address_edi_m2o
|
||||
edi_document.pop('partner_address', False) # ignored
|
||||
|
||||
return partner_id
|
||||
return address_id
|
||||
|
||||
|
||||
def edi_import(self, cr, uid, edi_document, context=None):
|
||||
|
||||
@@ -35,7 +35,7 @@ class payment_mode(osv.osv):
|
||||
domain=[('type', 'in', ('bank','cash'))], help='Bank or Cash Journal for the Payment Mode'),
|
||||
'company_id': fields.many2one('res.company', 'Company',required=True),
|
||||
'partner_id':fields.related('company_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True,),
|
||||
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id
|
||||
@@ -51,14 +51,14 @@ class payment_mode(osv.osv):
|
||||
JOIN payment_mode pm ON (pm.bank_id = pb.id)
|
||||
WHERE pm.id = %s """, [payment_code])
|
||||
return [x[0] for x in cr.fetchall()]
|
||||
|
||||
|
||||
def onchange_company_id (self, cr, uid, ids, company_id=False, context=None):
|
||||
result = {}
|
||||
if company_id:
|
||||
partner_id = self.pool.get('res.company').browse(cr, uid, company_id, context=context).partner_id.id
|
||||
result['partner_id'] = partner_id
|
||||
return {'value': result}
|
||||
|
||||
|
||||
|
||||
payment_mode()
|
||||
|
||||
@@ -191,21 +191,20 @@ class payment_line(osv.osv):
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
owner = line.order_id.mode.bank_id.partner_id
|
||||
result[line.id] = False
|
||||
if owner.address:
|
||||
for ads in owner.address:
|
||||
if ads.type == 'default':
|
||||
st = ads.street and ads.street or ''
|
||||
st1 = ads.street2 and ads.street2 or ''
|
||||
if 'zip_id' in ads:
|
||||
zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
|
||||
else:
|
||||
zip = ads.zip and ads.zip or ''
|
||||
city = ads.city and ads.city or ''
|
||||
zip_city = zip + ' ' + city
|
||||
cntry = ads.country_id and ads.country_id.name or ''
|
||||
info = owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||
result[line.id] = info
|
||||
break
|
||||
if owner:
|
||||
if owner.type == 'default':
|
||||
st = owner.street and owner.street or ''
|
||||
st1 = owner.street2 and owner.street2 or ''
|
||||
if 'zip_id' in owner:
|
||||
zip_city = owner.zip_id and partner_zip_obj.name_get(cr, uid, [owner.zip_id.id])[0][1] or ''
|
||||
else:
|
||||
zip = owner.zip and owner.zip or ''
|
||||
city = owner.city and owner.city or ''
|
||||
zip_city = zip + ' ' + city
|
||||
cntry = owner.country_id and owner.country_id.name or ''
|
||||
info = owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||
result[line.id] = info
|
||||
break
|
||||
return result
|
||||
|
||||
def info_partner(self, cr, uid, ids, name=None, args=None, context=None):
|
||||
@@ -219,18 +218,18 @@ class payment_line(osv.osv):
|
||||
if not line.partner_id:
|
||||
break
|
||||
partner = line.partner_id.name or ''
|
||||
if line.partner_id.address:
|
||||
for ads in line.partner_id.address:
|
||||
if ads.type == 'default':
|
||||
st = ads.street and ads.street or ''
|
||||
st1 = ads.street2 and ads.street2 or ''
|
||||
if 'zip_id' in ads:
|
||||
zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
|
||||
if line.partner_id:
|
||||
#for ads in line.partner_id.address:
|
||||
if line.partner_id.type == 'default':
|
||||
st = line.partner_id.street and line.partner_id.street or ''
|
||||
st1 = line.partner_id.street2 and line.partner_id.street2 or ''
|
||||
if 'zip_id' in line.partner_id:
|
||||
zip_city = line.partner_id.zip_id and partner_zip_obj.name_get(cr, uid, [line.partner_id.zip_id.id])[0][1] or ''
|
||||
else:
|
||||
zip = ads.zip and ads.zip or ''
|
||||
city = ads.city and ads.city or ''
|
||||
zip = line.partner_id.zip and line.partner_id.zip or ''
|
||||
city = line.partner_id.city and line.partner_id.city or ''
|
||||
zip_city = zip + ' ' + city
|
||||
cntry = ads.country_id and ads.country_id.name or ''
|
||||
cntry = line.partner_id.country_id and line.partner_id.country_id.name or ''
|
||||
info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||
result[line.id] = info
|
||||
break
|
||||
@@ -428,24 +427,23 @@ class payment_line(osv.osv):
|
||||
if partner_id:
|
||||
part_obj = partner_obj.browse(cr, uid, partner_id, context=context)
|
||||
partner = part_obj.name or ''
|
||||
if part_obj:
|
||||
#for ads in part_obj.address:
|
||||
if part_obj.type == 'default':
|
||||
st = part_obj.street and part_obj.street or ''
|
||||
st1 = part_obj.street2 and part_obj.street2 or ''
|
||||
|
||||
if part_obj.address:
|
||||
for ads in part_obj.address:
|
||||
if ads.type == 'default':
|
||||
st = ads.street and ads.street or ''
|
||||
st1 = ads.street2 and ads.street2 or ''
|
||||
if 'zip_id' in part_obj:
|
||||
zip_city = part_obj.zip_id and partner_zip_obj.name_get(cr, uid, [part_obj.zip_id.id])[0][1] or ''
|
||||
else:
|
||||
zip = part_obj.zip and part_obj.zip or ''
|
||||
city = part_obj.city and part_obj.city or ''
|
||||
zip_city = zip + ' ' + city
|
||||
|
||||
if 'zip_id' in ads:
|
||||
zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
|
||||
else:
|
||||
zip = ads.zip and ads.zip or ''
|
||||
city = ads.city and ads.city or ''
|
||||
zip_city = zip + ' ' + city
|
||||
cntry = part_obj.country_id and part_obj.country_id.name or ''
|
||||
info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||
|
||||
cntry = ads.country_id and ads.country_id.name or ''
|
||||
info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||
|
||||
data['info_partner'] = info
|
||||
data['info_partner'] = info
|
||||
|
||||
if part_obj.bank_ids and payment_type:
|
||||
bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, context=context)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
##############################################################################
|
||||
import logging
|
||||
|
||||
from osv import fields,osv
|
||||
from osv import fields,osv
|
||||
from edi import EDIMixin
|
||||
from openerp import SUPERUSER_ID
|
||||
from tools.translate import _
|
||||
@@ -74,9 +74,9 @@ class res_partner(osv.osv, EDIMixin):
|
||||
edi_bank_ids = edi_document.pop('bank_ids', None)
|
||||
contact_id = super(res_partner,self).edi_import(cr, uid, edi_document, context=context)
|
||||
if edi_bank_ids:
|
||||
contacts = self.browse(cr, uid, contact_id, context=context)
|
||||
contact = self.browse(cr, uid, contact_id, context=context)
|
||||
import_ctx = dict((context or {}),
|
||||
default_partner_id=contacts.parent_id.id,
|
||||
default_partner_id=contact.id,
|
||||
default_state=self._get_bank_type(cr, uid, context))
|
||||
for ext_bank_id, bank_name in edi_bank_ids:
|
||||
try:
|
||||
|
||||
@@ -153,13 +153,13 @@
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="before">
|
||||
<xpath expr="//page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="before">
|
||||
<field name="state" />
|
||||
<field name="bank" />
|
||||
<field name="bank" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- res.partner form bank list-->
|
||||
<!-- Adding Type and bank name -->
|
||||
<record id="l10nch_view_partner_bank_invoice_tree" model="ir.ui.view">
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
-
|
||||
-
|
||||
In order to test BVR printing. I create Partner data .
|
||||
-
|
||||
-
|
||||
!record {model: res.partner.category, id: res_partner_category_bvr}:
|
||||
name: Customers
|
||||
-
|
||||
I create BVR DUMMY Customer.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_bvr}:
|
||||
category_id:
|
||||
- res_partner_category_bvr
|
||||
name: BVR DUMMY
|
||||
-
|
||||
-
|
||||
I create contact address for BVR DUMMY.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_address_1}:
|
||||
partner_id: res_partner_bvr
|
||||
parent_id: res_partner_bvr
|
||||
street: Route de Bélario
|
||||
type: contact
|
||||
-
|
||||
-
|
||||
I create invoice address for BVR DUMMY.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_address_2}:
|
||||
partner_id: res_partner_bvr
|
||||
parent_id: res_partner_bvr
|
||||
street: Route de Bélario
|
||||
type: invoice
|
||||
-
|
||||
-
|
||||
I create delivery address for BVR DUMMY.
|
||||
-
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_address_3}:
|
||||
partner_id: res_partner_bvr
|
||||
parent_id: res_partner_bvr
|
||||
street: Route de Bélario
|
||||
type: delivery
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ def _create_dta(obj, cr, uid, data, context=None):
|
||||
or ''
|
||||
else:
|
||||
v['partner_country']= pline.partner_id.country_id \
|
||||
and pline.partner_id.acountry_id.name \
|
||||
and pline.partner_id.country_id.name \
|
||||
or ''
|
||||
else:
|
||||
v['partner_street'] =''
|
||||
|
||||
@@ -67,7 +67,7 @@ Dashboard for purchase management that includes:
|
||||
'test/process/generate_invoice_from_reception.yml',
|
||||
'test/process/run_scheduler.yml',
|
||||
'test/process/merge_order.yml',
|
||||
# 'test/process/edi_purchase_order.yml',
|
||||
'test/process/edi_purchase_order.yml',
|
||||
'test/process/invoice_on_poline.yml',
|
||||
'test/ui/print_report.yml',
|
||||
'test/ui/duplicate_order.yml',
|
||||
|
||||
@@ -65,7 +65,7 @@ class purchase_order(osv.osv, EDIMixin):
|
||||
"""Exports a purchase order"""
|
||||
edi_struct = dict(edi_struct or PURCHASE_ORDER_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 order in records:
|
||||
# generate the main report
|
||||
@@ -95,29 +95,22 @@ class purchase_order(osv.osv, EDIMixin):
|
||||
# the desired company among the user's allowed companies
|
||||
|
||||
self._edi_requires_attributes(('company_id','company_address'), edi_document)
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
res_partner_address = self.pool.get('res.partner')
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company = as a new partner
|
||||
src_company_id, src_company_name = edi_document.pop('company_id')
|
||||
partner_id = self.edi_import_relation(cr, uid, 'res.partner', src_company_name,
|
||||
src_company_id, context=context)
|
||||
partner_value = {'customer': True}
|
||||
res_partner.write(cr, uid, [partner_id], partner_value, context=context)
|
||||
|
||||
# imported company_address = new partner address
|
||||
src_company_id, src_company_name = edi_document.pop('company_id')
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['partner_id'] = (src_company_id, src_company_name)
|
||||
address_info['type'] = 'default'
|
||||
address_info['customer'] = True
|
||||
if 'name' not in address_info:
|
||||
address_info['name'] = src_company_name
|
||||
address_id = res_partner_address.edi_import(cr, uid, address_info, context=context)
|
||||
|
||||
# modify edi_document to refer to new partner/address
|
||||
partner_address = res_partner_address.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['partner_id'] = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
|
||||
return partner_id
|
||||
return address_id
|
||||
|
||||
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
|
||||
# TODO: refactor into common place for purchase/sale, e.g. into product module
|
||||
|
||||
@@ -101,28 +101,25 @@ class sale_order(osv.osv, EDIMixin):
|
||||
self._edi_requires_attributes(('company_id','company_address'), edi_document)
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company = as a new partner
|
||||
src_company_id, src_company_name = edi_document.pop('company_id')
|
||||
partner_id = self.edi_import_relation(cr, uid, 'res.partner', src_company_name,
|
||||
src_company_id, context=context)
|
||||
partner_value = {'supplier': True}
|
||||
res_partner.write(cr, uid, [partner_id], partner_value, context=context)
|
||||
|
||||
# imported company_address = new partner address
|
||||
src_company_id, src_company_name = edi_document.pop('company_id')
|
||||
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['parent_id'] = (src_company_id, src_company_name)
|
||||
address_info['type'] = 'default'
|
||||
address_info['supplier'] = True
|
||||
if 'name' not in address_info:
|
||||
address_info['name'] = src_company_name
|
||||
|
||||
address_id = res_partner.edi_import(cr, uid, address_info, context=context)
|
||||
|
||||
# modify edi_document to refer to new partner/address
|
||||
partner_address = res_partner.browse(cr, uid, address_id, context=context)
|
||||
# edi_document['parent_id'] = (src_company_id, src_company_name)
|
||||
edi_document.pop('partner_address', False) # ignored
|
||||
address_edi_m2o = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
edi_document['partner_id'] = address_edi_m2o
|
||||
edi_document['partner_invoice_id'] = address_edi_m2o
|
||||
edi_document['partner_shipping_id'] = address_edi_m2o
|
||||
|
||||
return partner_id
|
||||
return address_id
|
||||
|
||||
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
|
||||
# TODO: refactor into common place for purchase/sale, e.g. into product module
|
||||
@@ -210,7 +207,7 @@ class sale_order_line(osv.osv, EDIMixin):
|
||||
product_qty=line.product_uos_qty)
|
||||
|
||||
# company.security_days is for internal use, so customer should only
|
||||
# see the expected date_planned based on line.delay
|
||||
# see the expected date_planned based on line.delay
|
||||
date_planned = datetime.strptime(line.order_id.date_order, DEFAULT_SERVER_DATE_FORMAT) + \
|
||||
relativedelta(days=line.delay or 0.0)
|
||||
edi_doc['date_planned'] = date_planned.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
@@ -56,17 +56,16 @@
|
||||
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.some_address",
|
||||
"__module": "base",
|
||||
"__model": "res.partner",
|
||||
"name":"Chaussee",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
||||
"bank_ids": [
|
||||
["base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_bank-adaWadsadasdDJzGbp","Ladies bank: 032465789-156113"]
|
||||
],
|
||||
},
|
||||
"partner_id": ["purchase:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_test20", "jones white"],
|
||||
},
|
||||
"partner_id": ["purchase:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_test20", "jones white"],
|
||||
"order_line": [{
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-AlhsVDZGoKvJ",
|
||||
"__module": "purchase",
|
||||
|
||||
Reference in New Issue
Block a user