Remove _inherits
review670002
This commit is contained in:
+8
-16
@@ -17,7 +17,7 @@ __metaclass__ = PoolMeta
|
||||
class Company(ModelSQL, ModelView):
|
||||
'Company'
|
||||
__name__ = 'company.company'
|
||||
_inherits = {'party.party': 'party'}
|
||||
_rec_name = 'party'
|
||||
party = fields.Many2One('party.party', 'Party', required=True,
|
||||
ondelete='CASCADE')
|
||||
parent = fields.Many2One('company.company', 'Parent')
|
||||
@@ -36,19 +36,8 @@ class Company(ModelSQL, ModelView):
|
||||
super(Company, cls).validate(companies)
|
||||
cls.check_recursion(companies)
|
||||
|
||||
@classmethod
|
||||
def copy(cls, companies, default=None):
|
||||
Party = Pool().get('party.party')
|
||||
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
new_companies = []
|
||||
for company in companies:
|
||||
default['party'], = Party.copy([company.party])
|
||||
new_company, = super(Company, cls).copy([company], default=default)
|
||||
new_companies.append(new_company)
|
||||
return new_companies
|
||||
def get_rec_name(self, name):
|
||||
return self.party.rec_name
|
||||
|
||||
@classmethod
|
||||
def write(cls, companies, vals):
|
||||
@@ -60,10 +49,13 @@ class Company(ModelSQL, ModelView):
|
||||
class Employee(ModelSQL, ModelView):
|
||||
'Employee'
|
||||
__name__ = 'company.employee'
|
||||
_inherits = {'party.party': 'party'}
|
||||
_rec_name = 'party'
|
||||
party = fields.Many2One('party.party', 'Party', required=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
|
||||
def get_rec_name(self, name):
|
||||
return self.party.rec_name
|
||||
|
||||
|
||||
class UserEmployee(ModelSQL):
|
||||
'User - Employee'
|
||||
@@ -133,7 +125,7 @@ class User:
|
||||
def get_status_bar(self, name):
|
||||
status = super(User, self).get_status_bar(name)
|
||||
if self.company:
|
||||
status += ' - %s [%s]' % (self.company.name,
|
||||
status += ' - %s [%s]' % (self.company.rec_name,
|
||||
self.company.currency.name)
|
||||
return status
|
||||
|
||||
|
||||
+3
-10
@@ -6,7 +6,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.ui.view" id="company_view_form">
|
||||
<field name="model">company.company</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit" ref="party.party_view_form"/>
|
||||
<field name="inherit" eval="None"/>
|
||||
<field name="name">company_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="company_view_tree">
|
||||
@@ -166,18 +166,11 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.ui.view" id="employee_view_form">
|
||||
<field name="model">company.employee</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit" ref="party.party_view_form"/>
|
||||
<field name="inherit" eval="None"/>
|
||||
<field name="priority">10</field>
|
||||
<field name="name">employee_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="employee_view_form2">
|
||||
<field name="model">company.employee</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="name">employee_form2</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="employee_view_tree">
|
||||
<field name="model">company.employee</field>
|
||||
<field name="type">tree</field>
|
||||
@@ -195,7 +188,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_employee_form_view2">
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="view" ref="employee_view_form2"/>
|
||||
<field name="view" ref="employee_view_form"/>
|
||||
<field name="act_window" ref="act_employee_form"/>
|
||||
</record>
|
||||
<menuitem parent="party.menu_configuration" action="act_employee_form"
|
||||
|
||||
Binary file not shown.
+20
-7
@@ -22,6 +22,7 @@ class CompanyTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
trytond.tests.test_tryton.install_module('company')
|
||||
self.party = POOL.get('party.party')
|
||||
self.company = POOL.get('company.company')
|
||||
self.employee = POOL.get('company.employee')
|
||||
self.currency = POOL.get('currency.currency')
|
||||
@@ -49,8 +50,11 @@ class CompanyTestCase(unittest.TestCase):
|
||||
('code', '=', 'cu1'),
|
||||
], 0, 1, None)
|
||||
|
||||
company1, = self.company.create([{
|
||||
party1, = self.party.create([{
|
||||
'name': 'B2CK',
|
||||
}])
|
||||
company1, = self.company.create([{
|
||||
'party': party1.id,
|
||||
'currency': currency1.id,
|
||||
}])
|
||||
self.assert_(company1)
|
||||
@@ -66,11 +70,14 @@ class CompanyTestCase(unittest.TestCase):
|
||||
], 0, 1, None)
|
||||
|
||||
company1, = self.company.search([
|
||||
('name', '=', 'B2CK'),
|
||||
('rec_name', '=', 'B2CK'),
|
||||
], 0, 1, None)
|
||||
|
||||
company2, = self.company.create([{
|
||||
party2, = self.party.create([{
|
||||
'name': 'B2CK Branch',
|
||||
}])
|
||||
company2, = self.company.create([{
|
||||
'party': party2.id,
|
||||
'parent': company1.id,
|
||||
'currency': currency1.id,
|
||||
}])
|
||||
@@ -88,11 +95,14 @@ class CompanyTestCase(unittest.TestCase):
|
||||
with Transaction().start(DB_NAME, USER,
|
||||
context=CONTEXT) as transaction:
|
||||
company1, = self.company.search([
|
||||
('name', '=', 'B2CK'),
|
||||
('rec_name', '=', 'B2CK'),
|
||||
], 0, 1, None)
|
||||
|
||||
self.employee.create([{
|
||||
party, = self.party.create([{
|
||||
'name': 'Employee1',
|
||||
}])
|
||||
self.employee.create([{
|
||||
'party': party.id,
|
||||
'company': company1.id,
|
||||
}])
|
||||
transaction.cursor.commit()
|
||||
@@ -108,11 +118,14 @@ class CompanyTestCase(unittest.TestCase):
|
||||
], 0, 1, None)
|
||||
|
||||
company1, = self.company.search([
|
||||
('name', '=', 'B2CK'),
|
||||
('rec_name', '=', 'B2CK'),
|
||||
], 0, 1, None)
|
||||
|
||||
company2, = self.company.create([{
|
||||
party2, = self.party.create([{
|
||||
'name': 'B2CK Branch',
|
||||
}])
|
||||
company2, = self.company.create([{
|
||||
'party': party2.id,
|
||||
'parent': company1.id,
|
||||
'currency': currency1.id,
|
||||
}])
|
||||
|
||||
+8
-15
@@ -1,19 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form" position="replace_attributes">
|
||||
<form string="Company"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group[@id='checkboxes']" position="after">
|
||||
<label name="currency"/>
|
||||
<field name="currency"/>
|
||||
<label name="vat_country"/>
|
||||
<field name="vat_country"/>
|
||||
<label name="vat_number"/>
|
||||
<field name="vat_number"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
||||
<form string="Company">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="currency"/>
|
||||
<field name="currency"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Company" col="2" id="company">
|
||||
<label name="parent"/>
|
||||
<field name="parent"/>
|
||||
@@ -25,5 +18,5 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<separator name="footer"/>
|
||||
<field name="footer"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
</notebook>
|
||||
</form>
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree string="Companies">
|
||||
<field name="name"/>
|
||||
<field name="party"/>
|
||||
</tree>
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree string="Companies">
|
||||
<field name="name"/>
|
||||
<field name="party"/>
|
||||
<field name="currency"/>
|
||||
<field name="vat_code"/>
|
||||
<field name="parent" tree_invisible="1"/>
|
||||
<field name="childs" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form" position="replace_attributes">
|
||||
<form string="Employee"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/group/label[@name='active']" position="before">
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
</xpath>
|
||||
</data>
|
||||
<form string="Employee">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
</form>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form string="Employee">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
</form>
|
||||
@@ -2,6 +2,6 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree string="Employees">
|
||||
<field name="name"/>
|
||||
<field name="party"/>
|
||||
<field name="company"/>
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user