[FIX] account: fix transfer_account in settings + create sale/purchase tax template for l10n_generic_coa
This commit is contained in:
committed by
Cédric Snauwaert
parent
b30011d447
commit
73a3bea15e
@@ -53,6 +53,7 @@ class AccountConfigSettings(models.TransientModel):
|
||||
sale_tax_rate = fields.Float(string='Sales tax (%)')
|
||||
purchase_tax_rate = fields.Float(string='Purchase tax (%)')
|
||||
bank_account_code_char = fields.Char(string='Bank Accounts Code', related='company_id.bank_account_code_char', help='Define the code for the bank account')
|
||||
template_transfer_account_id = fields.Many2one('account.account.template', help="Intermediary account used when moving money from a liquidity account to another")
|
||||
transfer_account_id = fields.Many2one('account.account',
|
||||
related='company_id.transfer_account_id',
|
||||
domain=lambda self: [('reconcile', '=', True), ('user_type.id', '=', self.env.ref('account.data_account_type_current_assets').id)],
|
||||
@@ -212,7 +213,7 @@ class AccountConfigSettings(models.TransientModel):
|
||||
if self.chart_template_id.code_digits:
|
||||
self.code_digits = self.chart_template_id.code_digits
|
||||
if self.chart_template_id.transfer_account_id:
|
||||
self.transfer_account_id = self.chart_template_id.transfer_account_id.id
|
||||
self.template_transfer_account_id = self.chart_template_id.transfer_account_id.id
|
||||
if self.chart_template_id.bank_account_code_char:
|
||||
self.bank_account_code_char = self.chart_template_id.bank_account_code_char
|
||||
return {}
|
||||
@@ -246,6 +247,11 @@ class AccountConfigSettings(models.TransientModel):
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def set_transfer_account(self):
|
||||
if self.transfer_account_id and self.transfer_account_id != self.company_id.transfer_account_id:
|
||||
self.company_id.write({'transfer_account_id': self.transfer_account_id.id})
|
||||
|
||||
@api.multi
|
||||
def set_product_taxes(self):
|
||||
""" Set the product taxes if they have changed """
|
||||
@@ -264,7 +270,7 @@ class AccountConfigSettings(models.TransientModel):
|
||||
wizard = self.env['wizard.multi.charts.accounts'].create({
|
||||
'company_id': self.company_id.id,
|
||||
'chart_template_id': self.chart_template_id.id,
|
||||
'transfer_account_id': self.transfer_account_id.id,
|
||||
'transfer_account_id': self.template_transfer_account_id.id,
|
||||
'code_digits': self.code_digits or 6,
|
||||
'sale_tax': self.sale_tax.id,
|
||||
'purchase_tax': self.purchase_tax.id,
|
||||
|
||||
@@ -15,18 +15,21 @@ class TestSearch(AccountTestUsers):
|
||||
name="Tax Received",
|
||||
code="X121",
|
||||
user_type=ac_ids.id,
|
||||
reconcile=True,
|
||||
)).id, "X121 Tax Received"
|
||||
|
||||
self.apurchase = self.account_model.create(dict(
|
||||
name="Purchased Stocks",
|
||||
code="X1101",
|
||||
user_type=ac_ids.id,
|
||||
reconcile=True,
|
||||
)).id, "X1101 Purchased Stocks"
|
||||
|
||||
self.asale = self.account_model.create(dict(
|
||||
name="Product Sales",
|
||||
code="XX200",
|
||||
user_type=ac_ids.id,
|
||||
reconcile=True,
|
||||
)).id, "XX200 Product Sales"
|
||||
|
||||
self.all_ids = [self.atax[0], self.apurchase[0], self.asale[0]]
|
||||
|
||||
@@ -83,6 +83,10 @@
|
||||
<label for="purchase_tax_rate"/>
|
||||
<field name="purchase_tax_rate" />
|
||||
</div>
|
||||
<div attrs="{'invisible': ['|', ('chart_template_id','=',False), ('has_chart_of_accounts','!=',False)]}">
|
||||
<label for="template_transfer_account_id"/>
|
||||
<field name="template_transfer_account_id" class="oe_inline"/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
<group string="Fiscal Year">
|
||||
@@ -231,9 +235,9 @@
|
||||
class="oe_inline oe_link"/>
|
||||
<field name="company_footer"/>
|
||||
</div>
|
||||
<div>
|
||||
<div attrs="{'invisible': [('has_chart_of_accounts','=',False)]}">
|
||||
<label for="transfer_account_id"/>
|
||||
<field name="transfer_account_id" class="oe_inline" attrs="{'required': [('chart_template_id','!=',False)]}"/>
|
||||
<field name="transfer_account_id" class="oe_inline" attrs="{'required': [('has_chart_of_accounts','!=',False)]}"/>
|
||||
</div>
|
||||
<div name='payment_acquirer'>
|
||||
<label for="paypal_account"/>
|
||||
|
||||
@@ -228,6 +228,25 @@
|
||||
<field name="expense_currency_exchange_account_id" ref="exchange_fx_expense"/>
|
||||
</record>
|
||||
|
||||
<!-- Tax template for sale and purchase -->
|
||||
<record id="sale_tax_template" model="account.tax.template">
|
||||
<field name="chart_template_id" ref="configurable_chart_template"/>
|
||||
<field name="name">Tax 15%</field>
|
||||
<field name="amount">15</field>
|
||||
<field name="type_tax_use">sale</field>
|
||||
<field name="account_id" ref="conf_iva"/>
|
||||
<field name="refund_account_id" ref="conf_iva"/>
|
||||
</record>
|
||||
|
||||
<record id="purchase_tax_template" model="account.tax.template">
|
||||
<field name="chart_template_id" ref="configurable_chart_template"/>
|
||||
<field name="name">Purchase Tax 15%</field>
|
||||
<field name="amount">15</field>
|
||||
<field name="type_tax_use">purchase</field>
|
||||
<field name="account_id" ref="conf_ova"/>
|
||||
<field name="refund_account_id" ref="conf_ova"/>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<record id="otaxs" model="account.tax.template">
|
||||
<field name="chart_template_id" ref="configurable_chart_template"/>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
!python {model: sale.advance.payment.inv}: |
|
||||
ctx = context.copy()
|
||||
ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")})
|
||||
pay_id = self.create(cr, uid, {'advance_payment_method': 'fixed', 'amount': 5})
|
||||
pay_id = self.create(cr, uid, {'advance_payment_method': 'fixed', 'amount': 5, 'product_id': ref("sale_order_line_21")})
|
||||
self.create_invoices(cr, uid, [pay_id], context=ctx)
|
||||
invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids
|
||||
|
||||
|
||||
Reference in New Issue
Block a user