Code refactoring and improvement

This commit is contained in:
Youssef Elouahby 2018-10-12 01:48:10 +01:00
parent 2eda76a20d
commit 35c54abc15
2 changed files with 23 additions and 7 deletions

View File

@ -36,6 +36,10 @@ class PartnerArea(models.Model):
sequence = fields.Integer()
area_street_ids = fields.One2many('golem.partner.area.street', 'area_id',
string="street list")
parent_id = fields.Many2one('golem.partner.area', string="Parent Territory",
domain="[('id', '!=', id)]")
sub_territorie_ids = fields.One2many('golem.partner.area', 'parent_id',
string="Sub Territories List")
class ResPartner(models.Model):

View File

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tree>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="parent_id"/>
</tree>
</field>
</record>
@ -38,12 +39,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="arch" type="xml">
<form>
<group>
<field name="name"/>
<field name="area_street_ids">
<tree editable="bottom">
<field name="name"/>
</tree>
</field>
<group>
<field name="name"/>
<field name="area_street_ids">
<tree editable="bottom">
<field name="name"/>
</tree>
</field>
</group>
<group>
<field name="parent_id"/>
<field name="sub_territorie_ids" widget="many2many_tags"/>
</group>
</group>
</form>
</field>
@ -55,7 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="model">golem.partner.area</field>
<field name="arch" type="xml">
<search>
<field name="name" />
<field name="name"/>
<field name="parent_id"/>
<filter name="sub_territories" string="Sub Territories"
domain="[('parent_id', '!=', False)]"/>
<filter name="parent_territories" string="Parent Territories"
domain="[('sub_territorie_ids', '!=', False)]"/>
</search>
</field>
</record>