update customize, fix reset account

This commit is contained in:
ivan deng
2019-07-11 00:01:54 +08:00
parent b4aef620f6
commit 501070ba77
2 changed files with 82 additions and 8 deletions

View File

@@ -23,7 +23,7 @@
{ {
'name': 'Odoo Customize(Debranding, My Odoo)', 'name': 'Odoo Customize(Debranding, My Odoo)',
'version': '12.19.07.06', 'version': '12.19.07.10',
'author': 'Sunpop.cn', 'author': 'Sunpop.cn',
'category': 'Productivity', 'category': 'Productivity',
'website': 'https://www.sunpop.cn', 'website': 'https://www.sunpop.cn',
@@ -70,6 +70,7 @@
26. Add multi uninstall modules 26. Add multi uninstall modules
27. Add odoo 13 support, Just install this app on odoo 13, master branch of odoo github. 27. Add odoo 13 support, Just install this app on odoo 13, master branch of odoo github.
28. Fix pos remove data for account close. 28. Fix pos remove data for account close.
29. Fix account reset.
This module can help to white label the Odoo. This module can help to white label the Odoo.
Also helpful for training and support for your odoo end-user. Also helpful for training and support for your odoo end-user.

View File

@@ -268,6 +268,34 @@ class ResConfigSettings(models.TransientModel):
pass # raise Warning(e) pass # raise Warning(e)
return True return True
@api.multi
def remove_expense(self):
to_removes = [
# 清除
['hr.expense.sheet', ],
['hr.expense', ],
['hr.payslip', ],
['hr.payslip.run', ],
]
try:
for line in to_removes:
obj_name = line[0]
obj = self.pool.get(obj_name)
if obj:
sql = "delete from %s" % obj._table
self._cr.execute(sql)
# 更新序号
seqs = self.env['ir.sequence'].search([
('code', '=', 'hr.expense.invoice')])
for seq in seqs:
seq.write({
'number_next': 1,
})
self._cr.execute(sql)
except Exception as e:
pass # raise Warning(e)
return True
@api.multi @api.multi
def remove_mrp(self): def remove_mrp(self):
to_removes = [ to_removes = [
@@ -426,13 +454,63 @@ class ResConfigSettings(models.TransientModel):
def remove_account_chart(self): def remove_account_chart(self):
to_removes = [ to_removes = [
# 清除财务科目,用于重设 # 清除财务科目,用于重设
['res.partner.bank', ],
['res.bank', ],
['account.move.line'],
['account.invoice'],
['account.payment'],
['account.bank.statement', ],
['account.tax.account.tag', ], ['account.tax.account.tag', ],
['account.tax', ], ['account.tax', ],
['account.tax', ],
['account.account.account.tag', ], ['account.account.account.tag', ],
['wizard_multi_charts_accounts'], ['wizard_multi_charts_accounts'],
['account.account', ], ['account.account', ],
['account.journal', ], ['account.journal', ],
] ]
# 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)
self._cr.execute(sql)
except Exception as e:
pass # raise Warning(e)
try:
rec = self.env['res.partner'].search([])
for r in rec:
r.write({
'property_account_receivable_id': None,
'property_account_payable_id': None,
})
except Exception as e:
pass # raise Warning(e)
try:
rec = self.env['product.category'].search([])
for r in rec:
r.write({
'property_account_income_categ_id': None,
'property_account_expense_categ_id': None,
'property_account_creditor_price_difference_categ': None,
'property_stock_account_input_categ_id': None,
'property_stock_account_output_categ_id': None,
'property_stock_valuation_account_id': None,
})
except Exception as e:
pass # raise Warning(e)
try:
rec = self.env['stock.location'].search([])
for r in rec:
r.write({
'valuation_in_account_id': None,
'valuation_out_account_id': None,
})
except Exception as e:
pass # raise Warning(e)
try: try:
for line in to_removes: for line in to_removes:
obj_name = line[0] obj_name = line[0]
@@ -441,18 +519,13 @@ class ResConfigSettings(models.TransientModel):
sql = "delete from %s" % obj._table sql = "delete from %s" % obj._table
self._cr.execute(sql) self._cr.execute(sql)
# 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) sql = "update res_company set chart_template_id=null;"
self._cr.execute(sql)
sql = "update res_company set chart_template_id=null ;"
self._cr.execute(sql) self._cr.execute(sql)
# 更新序号 # 更新序号
except Exception as e: except Exception as e:
pass pass
return True return True
@api.multi @api.multi