FIX account_statement_operation_multicompany
This commit is contained in:
@@ -37,6 +37,9 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['account'],
|
||||
'data': ['security/rule.xml'],
|
||||
'data': [
|
||||
'account_view.xml',
|
||||
'security/rule.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -20,12 +20,27 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.exceptions import ValidationError
|
||||
|
||||
|
||||
class AccountStatementOperationTemplate(models.Model):
|
||||
_inherit = 'account.statement.operation.template'
|
||||
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company', related='account_id.company_id',
|
||||
store=True)
|
||||
'res.company', string='Company',
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'account.statement.operation.template'))
|
||||
|
||||
@api.one
|
||||
@api.constrains('account_id', 'company_id')
|
||||
def _check_company(self):
|
||||
if (
|
||||
self.account_id
|
||||
and self.company_id
|
||||
and self.account_id.company_id != self.company_id):
|
||||
raise ValidationError(
|
||||
_("The button %s is attached to the company %s but has an "
|
||||
"account in the company %s")
|
||||
% (self.name, self.company_id.name,
|
||||
self.account_id.company_id.name))
|
||||
|
||||
37
account_statement_operation_multicompany/account_view.xml
Normal file
37
account_statement_operation_multicompany/account_view.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 Akretion (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_statement_operation_template_form" model="ir.ui.view">
|
||||
<field name="name">account.statement.operation.multicompany.form</field>
|
||||
<field name="model">account.statement.operation.template</field>
|
||||
<field name="inherit_id" ref="account.view_account_statement_operation_template_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_id" position="after">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_statement_operation_template_tree" model="ir.ui.view">
|
||||
<field name="name">account.statement.operation.multicompany.tree</field>
|
||||
<field name="model">account.statement.operation.template</field>
|
||||
<field name="inherit_id" ref="account.view_account_statement_operation_template_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_id" position="after">
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
<field name="amount_type" position="after">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -14,7 +14,7 @@
|
||||
<field name="name">Account Statement Operation Template Multi-company</field>
|
||||
<field name="model_id" ref="account.model_account_statement_operation_template"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">[('company_id', '=', [user.company_id.id])]</field>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', '=', [user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user