本文整理汇总了Python中trytond.transaction.Transaction.dictfetchone方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.dictfetchone方法的具体用法?Python Transaction.dictfetchone怎么用?Python Transaction.dictfetchone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.transaction.Transaction
的用法示例。
在下文中一共展示了Transaction.dictfetchone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __register__
# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import dictfetchone [as 别名]
def __register__(cls, module_name):
pool = Pool()
Country = pool.get('country.country')
PartyAddress = pool.get('party.address')
PartyAFIPVatCountry = pool.get('party.afip.vat.country')
party_afip_vat_country = PartyAFIPVatCountry.__table__()
party_address = PartyAddress.__table__()
country = Country.__table__()
sql_table = cls.__table__()
cursor = Transaction().cursor
super(PartyIdentifier, cls).__register__(module_name)
identifiers = []
cursor.execute(*sql_table.select(
sql_table.id, sql_table.party, sql_table.code, sql_table.type))
for identifier_id, party_id, code_country, type in cursor.fetchall():
if not code_country or type is not None:
continue
type = None
code = None
vat_country = ''
if code_country.startswith('AR'):
code = code_country[2:]
if len(code) < 11:
type = 'ar_dni'
elif cuit.is_valid(code):
type = 'ar_cuit'
else:
code = code_country
type = 'ar_foreign'
cursor_pa = Transaction().cursor
cursor_pa.execute(*party_address.join(country,
condition=party_address.country == country.id
).select(country.code,
where=(party_address.party == party_id)))
row = cursor_pa.dictfetchone()
if row:
vat_country = row['code']
country, = Country.search([('code','=',vat_country)])
cursor_pa = Transaction().cursor
cursor_pa.execute(*party_afip_vat_country.select(
party_afip_vat_country.vat_country,
where=(party_afip_vat_country.vat_number == code)))
afip_vat_country = cursor_pa.dictfetchone()
if afip_vat_country is None:
afip_vat_countrys = []
country, = Country.search([('code','=',vat_country)])
afip_vat_countrys.append(
PartyAFIPVatCountry(type_code='0', vat_country=country, vat_number=code))
PartyAFIPVatCountry.save(afip_vat_countrys)
identifiers.append(
cls(id=identifier_id, code=code, type=type, vat_country=vat_country))
cls.save(identifiers)
示例2: __register__
# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import dictfetchone [as 别名]
def __register__(cls, module_name):
pool = Pool()
Country = pool.get('country.country')
Party = pool.get('party.party')
PartyAddress = pool.get('party.address')
PartyAFIPVatCountry = pool.get('party.afip.vat.country')
party_afip_vat_country = PartyAFIPVatCountry.__table__()
party_address = PartyAddress.__table__()
party = Party.__table__()
country_table = Country.__table__()
sql_table = cls.__table__()
cursor = Transaction().connection.cursor()
TableHandler = backend.get('TableHandler')
table_a = TableHandler(cls, module_name)
super(PartyIdentifier, cls).__register__(module_name)
identifiers = []
cursor.execute(*sql_table.select(
sql_table.id, sql_table.party, sql_table.code, sql_table.type,
where=(sql_table.code != 'AR')))
for identifier_id, party_id, code_country, identifier_type in cursor.fetchall():
identifiers = []
if not code_country or identifier_type is not None:
continue
type = identifier_type
code = None
vat_country = ''
cursor.execute(*party.select(
party.tipo_documento, where=(party.id == party_id)))
party_row = cursor.dictfetchone()
if party_row['tipo_documento'] and party_row['tipo_documento'] == '96' and len(code_country) < 11:
code = code_country
type = 'ar_dni'
elif code_country.startswith('AR'):
code = code_country[2:]
if cuit.is_valid(code):
type = 'ar_cuit'
else:
type = identifier_type
elif len(code_country) < 11:
code = code_country
type = 'ar_dni'
else:
code = code_country
type = 'ar_foreign'
cursor_pa = Transaction().connection.cursor()
cursor_pa.execute(*party_address.join(country_table,
condition=party_address.country == country_table.id).select(country_table.code,
where=(party_address.party == party_id)))
row = cursor_pa.dictfetchone()
if row:
vat_country = row['code']
country, = Country.search([('code', '=', vat_country)])
cursor_pa = Transaction().connection.cursor()
cursor_pa.execute(*party_afip_vat_country.select(
party_afip_vat_country.vat_country,
where=(party_afip_vat_country.vat_number == code)))
afip_vat_country = cursor_pa.dictfetchone()
if afip_vat_country is None:
afip_vat_countrys = []
country, = Country.search([('code','=',vat_country)])
afip_vat_countrys.append(
PartyAFIPVatCountry(type_code='0', vat_country=country, vat_number=code))
PartyAFIPVatCountry.save(afip_vat_countrys)
identifiers.append(
cls(id=identifier_id, code=code, type=type, vat_country=vat_country))
cls.save(identifiers)
# Migrate to 4.0
if table_a.column_exist('vat_country'):
cursor.execute(*sql_table.select(
sql_table.id, sql_table.vat_country, sql_table.country,
where=(sql_table.type == 'ar_foreign')))
for identifier_id, vat_country, country in cursor.fetchall():
if vat_country != '':
country_code, = Country.search([('code','=',vat_country)])
cursor.execute(*sql_table.update(
[sql_table.country, sql_table.vat_country], [country_code.id, ''],
where=(sql_table.id == identifier_id)))
table_a.drop_column('vat_country')