| 1 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 |
from odoo import models |
| 3 |
from odoo.addons.account.models.chart_template import template |
| 4 |
|
| 5 |
|
| 6 |
class AccountChartTemplate(models.AbstractModel): |
| 7 |
_inherit = 'account.chart.template' |
| 8 |
|
| 9 |
@template('us') |
| 10 |
def _get_us_template_data(self): |
| 11 |
return { |
| 12 |
'property_account_receivable_id': 'account_account_us_receivable', |
| 13 |
'property_account_payable_id': 'account_account_us_payable', |
| 14 |
} |
| 15 |
|
| 16 |
@template('us', 'res.company') |
| 17 |
def _get_us_res_company(self): |
| 18 |
# Default to the right state taxes. If the company doesn't have their state |
| 19 |
# selected at the time the localization is installed, then it will default |
| 20 |
# to 6% as that is the most common tax (both by #states and population). |
| 21 |
default_sales_tax, default_purchase_tax = { |
| 22 |
'AL': ('account_tax_us_sale_4', 'account_tax_us_purchase_4'), |
| 23 |
'AK': ('account_tax_us_sale_0', 'account_tax_us_purchase_0'), |
| 24 |
'AZ': ('account_tax_us_sale_5_6', 'account_tax_us_purchase_5_6'), |
| 25 |
'AR': ('account_tax_us_sale_6_5', 'account_tax_us_purchase_6_5'), |
| 26 |
'CA': ('account_tax_us_sale_7_25', 'account_tax_us_purchase_7_25'), |
| 27 |
'CO': ('account_tax_us_sale_2_9', 'account_tax_us_purchase_2_9'), |
| 28 |
'CT': ('account_tax_us_sale_6_35', 'account_tax_us_purchase_6_35'), |
| 29 |
'DE': ('account_tax_us_sale_0', 'account_tax_us_purchase_0'), |
| 30 |
'FL': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 31 |
'GA': ('account_tax_us_sale_4', 'account_tax_us_purchase_4'), |
| 32 |
'HI': ('account_tax_us_sale_4', 'account_tax_us_purchase_4'), |
| 33 |
'ID': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 34 |
'IL': ('account_tax_us_sale_6_25', 'account_tax_us_purchase_6_25'), |
| 35 |
'IN': ('account_tax_us_sale_7', 'account_tax_us_purchase_7'), |
| 36 |
'IA': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 37 |
'KS': ('account_tax_us_sale_6_5', 'account_tax_us_purchase_6_5'), |
| 38 |
'KY': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 39 |
'LA': ('account_tax_us_sale_5', 'account_tax_us_purchase_5'), |
| 40 |
'ME': ('account_tax_us_sale_5_5', 'account_tax_us_purchase_5_5'), |
| 41 |
'MD': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 42 |
'MA': ('account_tax_us_sale_6_25', 'account_tax_us_purchase_6_25'), |
| 43 |
'MI': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 44 |
'MN': ('account_tax_us_sale_6_875', 'account_tax_us_purchase_6_875'), |
| 45 |
'MS': ('account_tax_us_sale_7', 'account_tax_us_purchase_7'), |
| 46 |
'MO': ('account_tax_us_sale_4_225', 'account_tax_us_purchase_4_225'), |
| 47 |
'MT': ('account_tax_us_sale_0', 'account_tax_us_purchase_0'), |
| 48 |
'NE': ('account_tax_us_sale_5_5', 'account_tax_us_purchase_5_5'), |
| 49 |
'NV': ('account_tax_us_sale_6_85', 'account_tax_us_purchase_6_85'), |
| 50 |
'NH': ('account_tax_us_sale_0', 'account_tax_us_purchase_0'), |
| 51 |
'NJ': ('account_tax_us_sale_6_625', 'account_tax_us_purchase_6_625'), |
| 52 |
'NM': ('account_tax_us_sale_4_875', 'account_tax_us_purchase_4_875'), |
| 53 |
'NY': ('account_tax_us_sale_4', 'account_tax_us_purchase_4'), |
| 54 |
'NC': ('account_tax_us_sale_4_75', 'account_tax_us_purchase_4_75'), |
| 55 |
'ND': ('account_tax_us_sale_5', 'account_tax_us_purchase_5'), |
| 56 |
'OH': ('account_tax_us_sale_5_75', 'account_tax_us_purchase_5_75'), |
| 57 |
'OK': ('account_tax_us_sale_4_5', 'account_tax_us_purchase_4_5'), |
| 58 |
'OR': ('account_tax_us_sale_0', 'account_tax_us_purchase_0'), |
| 59 |
'PA': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 60 |
'RI': ('account_tax_us_sale_7', 'account_tax_us_purchase_7'), |
| 61 |
'SC': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 62 |
'SD': ('account_tax_us_sale_4_2', 'account_tax_us_purchase_4_2'), |
| 63 |
'TN': ('account_tax_us_sale_7', 'account_tax_us_purchase_7'), |
| 64 |
'TX': ('account_tax_us_sale_6_25', 'account_tax_us_purchase_6_25'), |
| 65 |
'UT': ('account_tax_us_sale_6_1', 'account_tax_us_purchase_6_1'), |
| 66 |
'VT': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 67 |
'VA': ('account_tax_us_sale_5_3', 'account_tax_us_purchase_5_3'), |
| 68 |
'WA': ('account_tax_us_sale_6_5', 'account_tax_us_purchase_6_5'), |
| 69 |
'WV': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 70 |
'WI': ('account_tax_us_sale_5', 'account_tax_us_purchase_5'), |
| 71 |
'WY': ('account_tax_us_sale_4', 'account_tax_us_purchase_4'), |
| 72 |
'DC': ('account_tax_us_sale_6', 'account_tax_us_purchase_6'), |
| 73 |
}.get(self.env.company.state_id.code, ('account_tax_us_sale_6', 'account_tax_us_purchase_6')) |
| 74 |
return { |
| 75 |
self.env.company.id: { |
| 76 |
'anglo_saxon_accounting': True, |
| 77 |
'account_fiscal_country_id': 'base.us', |
| 78 |
'bank_account_code_prefix': '1014', |
| 79 |
'cash_account_code_prefix': '1015', |
| 80 |
'transfer_account_code_prefix': '1017', |
| 81 |
'account_default_pos_receivable_account_id': 'account_account_us_pos_receivable', |
| 82 |
'income_currency_exchange_account_id': 'account_account_us_income_currency_exchange', |
| 83 |
'expense_currency_exchange_account_id': 'account_account_us_expense_currency_exchange', |
| 84 |
'default_cash_difference_income_account_id': 'account_account_us_cash_diff_income', |
| 85 |
'default_cash_difference_expense_account_id': 'account_account_us_cash_diff_expense', |
| 86 |
'account_journal_early_pay_discount_loss_account_id': 'account_account_us_cash_discount_loss', |
| 87 |
'account_journal_early_pay_discount_gain_account_id': 'account_account_us_cash_discount_gain', |
| 88 |
'expense_account_id': 'account_account_us_expense', |
| 89 |
'income_account_id': 'account_account_us_income', |
| 90 |
'account_sale_tax_id': default_sales_tax, |
| 91 |
'account_purchase_tax_id': default_purchase_tax, |
| 92 |
'account_stock_journal_id': 'inventory_valuation', |
| 93 |
'account_stock_valuation_id': 'account_account_us_inventory_valuation', |
| 94 |
}, |
| 95 |
} |
| 96 |
|
| 97 |
def _get_accounts_data_values(self, company, template_data, bank_prefix='', code_digits=0): |
| 98 |
accounts_data = super()._get_accounts_data_values(company, template_data, bank_prefix=bank_prefix, code_digits=code_digits) |
| 99 |
if company.account_fiscal_country_id.code == 'US': |
| 100 |
accounts_data['transfer_account_id'].update({ |
| 101 |
'name': self.env._('Funds in Transit'), |
| 102 |
}) |
| 103 |
return accounts_data |
| 104 |
|
| 105 |
@template('us', 'account.account') |
| 106 |
def _get_us_account_account(self): |
| 107 |
return { |
| 108 |
'account_account_us_inventory_valuation': { |
| 109 |
'account_stock_variation_id': 'account_account_us_raw_materials', |
| 110 |
}, |
| 111 |
} |