mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update common
This commit is contained in:
@@ -128,6 +128,12 @@ class ResConfigSettings(models.TransientModel):
|
||||
t_name = obj._table
|
||||
|
||||
sql = "delete from %s" % t_name
|
||||
# 增加多公司处理
|
||||
if hasattr(self.env[obj_name], 'company_id'):
|
||||
field = self.env[obj_name]._fields['company_id']
|
||||
if not field.related or field.store:
|
||||
sql = "%s where company_id=%d" % (sql, self.env.company.id)
|
||||
_logger.warning('remove_app_data where add company_id: %s' % obj_name)
|
||||
try:
|
||||
self._cr.execute(sql)
|
||||
# self._cr.commit()
|
||||
@@ -310,6 +316,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
|
||||
# extra 更新序号
|
||||
domain = [
|
||||
('company_id', '=', self.env.company.id),
|
||||
'|', ('code', '=ilike', 'account.%'),
|
||||
'|', ('prefix', '=ilike', 'BNK1/%'),
|
||||
'|', ('prefix', '=ilike', 'CSH1/%'),
|
||||
@@ -330,10 +337,11 @@ class ResConfigSettings(models.TransientModel):
|
||||
return res
|
||||
|
||||
def remove_account_chart(self):
|
||||
company_id = self.env.company.id
|
||||
self = self.with_context(force_company=company_id, company_id=company_id)
|
||||
to_removes = [
|
||||
# 清除财务科目,用于重设
|
||||
'res.partner.bank',
|
||||
'res.bank',
|
||||
'account.move.line',
|
||||
'account.invoice',
|
||||
'account.payment',
|
||||
@@ -348,17 +356,17 @@ class ResConfigSettings(models.TransientModel):
|
||||
# todo: 要做 remove_hr,因为工资表会用到 account
|
||||
# 更新account关联,很多是多公司字段,故只存在 ir_property,故在原模型,只能用update
|
||||
try:
|
||||
# reset default tax,不管多公司
|
||||
field1 = self.env['ir.model.fields']._get('product.template', "taxes_id").id
|
||||
field2 = self.env['ir.model.fields']._get('product.template', "supplier_taxes_id").id
|
||||
|
||||
sql = ("delete from ir_default where field_id = %s or field_id = %s") % (field1, field2)
|
||||
sql2 = ("update account_journal set bank_account_id=NULL;")
|
||||
sql = "delete from ir_default where (field_id = %s or field_id = %s) and company_id=%d" \
|
||||
% (field1, field2, company_id)
|
||||
sql2 = "update account_journal set bank_account_id=NULL where company_id=%d;" % company_id
|
||||
self._cr.execute(sql)
|
||||
self._cr.execute(sql2)
|
||||
self._cr.commit()
|
||||
except Exception as e:
|
||||
pass # raise Warning(e)
|
||||
_logger.error('remove data error: %s,%s', 'account_chart: set tax and account_journal', e)
|
||||
try:
|
||||
rec = self.env['res.partner'].search([])
|
||||
for r in rec:
|
||||
@@ -392,7 +400,9 @@ class ResConfigSettings(models.TransientModel):
|
||||
pass # raise Warning(e)
|
||||
|
||||
seqs = []
|
||||
return self.remove_app_data(to_removes, seqs)
|
||||
res = self.remove_app_data(to_removes, seqs)
|
||||
self.env.company.write({'chart_template_id': False})
|
||||
return res
|
||||
|
||||
def remove_project(self):
|
||||
to_removes = [
|
||||
|
||||
@@ -144,8 +144,12 @@
|
||||
</div>
|
||||
<div class="col-12 col-lg-12 mb4">
|
||||
<span class="col-3 col-lg-2 text-left">Accounting</span>
|
||||
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." groups="base.group_multi_company"/>
|
||||
<button string="Delete All Voucher/Invoice/Bill" type="object" name="remove_account"
|
||||
confirm="Please confirm to delete the select data?" class="oe_highlight"/>
|
||||
|
|
||||
<button string="Clean and reset Account Chart" type="object" name="remove_account_chart"
|
||||
confirm="Please confirm to delete the select data?" class="oe_highlight"/>
|
||||
</div>
|
||||
<div class="col-12 col-lg-12 mb4">
|
||||
<span class="col-3 col-lg-2 text-left">Project</span>
|
||||
@@ -179,9 +183,6 @@
|
||||
<button string="Delete All Workflow" type="object" name="remove_workflow"
|
||||
confirm="Please confirm to delete the select data?" class="oe_highlight"/>
|
||||
|
|
||||
<button string="Clean and reset Account Chart" type="object" name="remove_account_chart"
|
||||
confirm="Please confirm to delete the select data?" class="oe_highlight"/>
|
||||
|
|
||||
<button string="Reset Category And Location Complete Name" type="object" name="reset_cat_loc_name" class="oe_highlight"/>
|
||||
</div>
|
||||
<div class="col-12 col-lg-12 mb4">
|
||||
|
||||
Reference in New Issue
Block a user