Maxime Chambreuil
4 years ago
committed by
joseph
24 changed files with 558 additions and 0 deletions
-
21animal/README.rst
-
3animal/__init__.py
-
29animal/__manifest__.py
-
25animal/data/animal.breed.csv
-
2animal/data/animal.color.csv
-
4animal/data/animal.species.csv
-
2animal/data/ir.module.category.csv
-
8animal/models/__init__.py
-
42animal/models/animal.py
-
12animal/models/animal_breed.py
-
14animal/models/animal_color.py
-
12animal/models/animal_species.py
-
3animal/readme/CONTRIBUTORS.rst
-
1animal/readme/DESCRIPTION.rst
-
3animal/readme/USAGE.rst
-
8animal/security/ir.model.access.csv
-
10animal/security/res_groups.xml
-
BINanimal/static/description/icon.png
-
BINanimal/static/img/avatar.png
-
156animal/views/animal.xml
-
53animal/views/animal_breed.xml
-
55animal/views/animal_color.xml
-
54animal/views/animal_species.xml
-
41animal/views/menu.xml
@ -0,0 +1,21 @@ |
|||
**This file is going to be generated by oca-gen-addon-readme.** |
|||
|
|||
*Manual changes will be overwritten.* |
|||
|
|||
Please provide content in the ``readme`` directory: |
|||
|
|||
* **DESCRIPTION.rst** (required) |
|||
* INSTALL.rst (optional) |
|||
* CONFIGURE.rst (optional) |
|||
* **USAGE.rst** (optional, highly recommended) |
|||
* DEVELOP.rst (optional) |
|||
* ROADMAP.rst (optional) |
|||
* HISTORY.rst (optional, recommended) |
|||
* **CONTRIBUTORS.rst** (optional, highly recommended) |
|||
* CREDITS.rst (optional) |
|||
|
|||
Content of this README will also be drawn from the addon manifest, |
|||
from keys such as name, authors, maintainers, development_status, |
|||
and license. |
|||
|
|||
A good, one sentence summary in the manifest is also highly recommended. |
@ -0,0 +1,3 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from . import models |
@ -0,0 +1,29 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
{ |
|||
"name": "Animal", |
|||
"version": "12.0.1.0.0", |
|||
"license": "AGPL-3", |
|||
"summary": "Manage animals information", |
|||
"author": "Open Source Integrators, Odoo Community Association (OCA)", |
|||
"maintainer": "Open Source Integrators", |
|||
"website": "https://github.com/OCA/partner-contact", |
|||
"depends": ["mail"], |
|||
"data": [ |
|||
"data/ir.module.category.csv", |
|||
"data/animal.species.csv", |
|||
"data/animal.breed.csv", |
|||
"data/animal.color.csv", |
|||
"security/res_groups.xml", |
|||
"security/ir.model.access.csv", |
|||
"views/animal_color.xml", |
|||
"views/animal_breed.xml", |
|||
"views/animal_species.xml", |
|||
"views/animal.xml", |
|||
"views/menu.xml", |
|||
], |
|||
"demo": [], |
|||
"application": True, |
|||
"development_status": "Beta", |
|||
"maintainers": ["max3903"], |
|||
} |
@ -0,0 +1,25 @@ |
|||
id,name,species_id/id |
|||
beagle,Beagle,animal.dog |
|||
boxer,Boxer,animal.dog |
|||
bull_terrier,Bull Terrier,animal.dog |
|||
bulldog,Bulldog,animal.dog |
|||
chihuahua,Chihuahua,animal.dog |
|||
cocker,Cocker,animal.dog |
|||
collie,Collie,animal.dog |
|||
dalmatian,Dalmatian,animal.dog |
|||
dachshund,Dachshund,animal.dog |
|||
doberman,Doberman,animal.dog |
|||
english_cocker_spaniel,English Cocker Spaniel,animal.dog |
|||
french_bulldog,French Bulldog,animal.dog |
|||
german_shepard,German Shepard,animal.dog |
|||
golden_retriever,Golden Retriever,animal.dog |
|||
great_dane,Great Dane,animal.dog |
|||
jack_russell,Jack Russell,animal.dog |
|||
labrador,Labrador,animal.dog |
|||
pomeranian,Pomeranian,animal.dog |
|||
pug,Pug,animal.dog |
|||
rottweiler,Rottweiler,animal.dog |
|||
schnauzer,Schnauzer,animal.dog |
|||
shih_tzu,Shih Tzu,animal.dog |
|||
siberian_husky,Siberian Husky,animal.dog |
|||
yorkshire_terrier,Yorkshire Terrier,animal.dog |
@ -0,0 +1,2 @@ |
|||
id,name,breed_id/id |
|||
salt,Salt and pepper,animal.schnauzer |
@ -0,0 +1,4 @@ |
|||
id,name |
|||
bird,Bird |
|||
cat,Cat |
|||
dog,Dog |
@ -0,0 +1,2 @@ |
|||
id,name,sequence |
|||
animal,Animal,30 |
@ -0,0 +1,8 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from . import ( |
|||
animal_species, |
|||
animal_breed, |
|||
animal_color, |
|||
animal, |
|||
) |
@ -0,0 +1,42 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class Animal(models.Model): |
|||
_name = "animal" |
|||
_description = "Animal" |
|||
_inherit = ["mail.thread", "mail.activity.mixin"] |
|||
_order = "name" |
|||
|
|||
name = fields.Char(string="Name") |
|||
ref = fields.Char(string="Reference") |
|||
species_id = fields.Many2one("animal.species", string="Species", required=True) |
|||
breed_id = fields.Many2one("animal.breed", string="Breed", required=True) |
|||
color_id = fields.Many2one("animal.color", string="Color") |
|||
size = fields.Char(string="Size") |
|||
weight = fields.Float(string="Weight (in kg)") |
|||
birth_date = fields.Date(string="Birth Date") |
|||
gender = fields.Selection( |
|||
string="Gender", |
|||
selection=[ |
|||
("female", "Female"), |
|||
("male", "Male"), |
|||
("hermaphrodite", "Hermaphrodite"), |
|||
("neutered", "Neutered"), |
|||
], |
|||
default="female", |
|||
required=True, |
|||
) |
|||
active = fields.Boolean(default=True) |
|||
image = fields.Binary( |
|||
"Image", attachment=True, help="This field holds the photo of the animal." |
|||
) |
|||
|
|||
@api.onchange("species_id") |
|||
def onchange_species(self): |
|||
self.breed_id = False |
|||
|
|||
@api.onchange("breed_id") |
|||
def onchange_breed(self): |
|||
self.color_id = False |
@ -0,0 +1,12 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class AnimalBreed(models.Model): |
|||
_name = "animal.breed" |
|||
_description = "Animal Breeds" |
|||
_order = "name" |
|||
|
|||
name = fields.Char(string="Name", translate=True) |
|||
species_id = fields.Many2one("animal.species", string="Species", required=True) |
@ -0,0 +1,14 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class AnimalColor(models.Model): |
|||
_name = "animal.color" |
|||
_description = "Animal Colors" |
|||
|
|||
name = fields.Char(string="Name", translate=True) |
|||
breed_id = fields.Many2one("animal.breed", string="Breed", required=True) |
|||
species_id = fields.Many2one( |
|||
"animal.species", string="Species", related="breed_id.species_id", readonly=True |
|||
) |
@ -0,0 +1,12 @@ |
|||
# Copyright (C) 2020 Open Source Integrators |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class AnimalSpecies(models.Model): |
|||
_name = "animal.species" |
|||
_description = "Animal Species" |
|||
_order = "name" |
|||
|
|||
name = fields.Char(string="Name", translate=True) |
|||
breed_ids = fields.One2many("animal.breed", "species_id", string="Breeds") |
@ -0,0 +1,3 @@ |
|||
* Open Source Integrators <https://www.opensourceintegrators.com> |
|||
|
|||
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com> |
@ -0,0 +1 @@ |
|||
This module allows you to store animal information. |
@ -0,0 +1,3 @@ |
|||
* Go to Animals |
|||
* Create an animal by entering his name and selecting his gender, species, breed and |
|||
color. |
@ -0,0 +1,8 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
|||
access_animal_user,animal.user,model_animal,base.group_user,1,1,1,1 |
|||
access_animal_color_user,animal.color.user,model_animal_color,base.group_user,1,0,0,0 |
|||
access_animal_color_manager,animal.color.manaager,model_animal_color,animal.group_animal_manager,1,1,1,1 |
|||
access_animal_breed_user,animal.breed.user,model_animal_breed,base.group_user,1,0,0,0 |
|||
access_animal_breed_manager,animal.breed.manager,model_animal_breed,animal.group_animal_manager,1,1,1,1 |
|||
access_animal_species_user,animal.species.user,model_animal_species,base.group_user,1,0,0,0 |
|||
access_animal_species_manager,animal.species.manager,model_animal_species,animal.group_animal_manager,1,1,1,0 |
@ -0,0 +1,10 @@ |
|||
<odoo> |
|||
|
|||
<!-- Animal groups --> |
|||
<record id="group_animal_manager" model="res.groups"> |
|||
<field name="name">Manager</field> |
|||
<field name="category_id" ref="animal"/> |
|||
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/> |
|||
</record> |
|||
|
|||
</odoo> |
After Width: 591 | Height: 592 | Size: 37 KiB |
After Width: 2130 | Height: 2130 | Size: 86 KiB |
@ -0,0 +1,156 @@ |
|||
<odoo> |
|||
|
|||
<!-- Animal Tree View --> |
|||
<record id="view_animal_tree" model="ir.ui.view"> |
|||
<field name="name">animal.tree</field> |
|||
<field name="model">animal</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Animals"> |
|||
<field name="ref"/> |
|||
<field name="name"/> |
|||
<field name="gender"/> |
|||
<field name="species_id"/> |
|||
<field name="breed_id"/> |
|||
<field name="color_id"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Animal Form View --> |
|||
<record id="view_animal_form" model="ir.ui.view"> |
|||
<field name="name">animal.form</field> |
|||
<field name="model">animal</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Animal"> |
|||
<header/> |
|||
<sheet> |
|||
<div class="oe_button_box" name="button_box"> |
|||
<button name="toggle_active" type="object" |
|||
class="oe_stat_button" icon="fa-archive"> |
|||
<field name="active" widget="boolean_button" |
|||
options='{"terminology": "archive"}'/> |
|||
</button> |
|||
</div> |
|||
<field name="image" widget='image' class="oe_avatar"/> |
|||
<div class="oe_title"> |
|||
<h1> |
|||
<field name="name"/> |
|||
</h1> |
|||
<field name="gender" widget="radio" |
|||
options="{'horizontal': true}"/> |
|||
</div> |
|||
<group id="main"> |
|||
<group id="left"> |
|||
<field name="species_id"/> |
|||
<field name="breed_id" domain="[('species_id', '=', species_id)]"/> |
|||
<field name="color_id" domain="[('breed_id', '=', breed_id)]"/> |
|||
<field name="size"/> |
|||
</group> |
|||
<group id="right"> |
|||
<field name="ref"/> |
|||
<field name="weight"/> |
|||
<field name="birth_date"/> |
|||
</group> |
|||
</group> |
|||
<notebook/> |
|||
</sheet> |
|||
<div class="oe_chatter"> |
|||
<field name="message_follower_ids" |
|||
widget="mail_followers"/> |
|||
<field name="activity_ids" widget="mail_activity"/> |
|||
<field name="message_ids" widget="mail_thread" |
|||
options="{'post_refresh': 'recipients'}"/> |
|||
</div> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Animal Kanban View --> |
|||
<record id="view_animal_kanban" model="ir.ui.view"> |
|||
<field name="name">animal.kanban</field> |
|||
<field name="model">animal</field> |
|||
<field name="arch" type="xml"> |
|||
<kanban class="o_res_partner_kanban"> |
|||
<field name="id"/> |
|||
<field name="image"/> |
|||
<field name="name"/> |
|||
<templates> |
|||
<t t-name="kanban-box"> |
|||
<div class="oe_kanban_global_click o_kanban_record_has_image_fill o_res_partner_kanban"> |
|||
<t t-if="record.image.raw_value"> |
|||
<img class="o_kanban_image" t-att-src="kanban_image('animal', 'image', record.id.raw_value)" t-att-alt="record.name"/> |
|||
</t> |
|||
<t t-else=""> |
|||
<img class="o_kanban_image" alt="Avatar" t-att-src='_s + "/animal/static/img/avatar.png"'/> |
|||
</t> |
|||
<div class="oe_kanban_details"> |
|||
<strong class="o_kanban_record_title oe_partner_heading"><field name="display_name"/></strong> |
|||
<div class="o_kanban_tags_section oe_kanban_partner_categories"/> |
|||
<ul> |
|||
<li t-if="record.gender.raw_value"><field name="gender"/></li> |
|||
<li t-if="record.species_id.raw_value and record.breed_id.raw_value"><field name="breed_id"/>, <field name="species_id"/></li> |
|||
</ul> |
|||
<div class="oe_kanban_partner_links"/> |
|||
</div> |
|||
</div> |
|||
</t> |
|||
</templates> |
|||
</kanban> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Search for animal --> |
|||
<record id="view_animal_search" model="ir.ui.view"> |
|||
<field name="name">animal.search</field> |
|||
<field name="model">animal</field> |
|||
<field name="arch" type="xml"> |
|||
<search string="Animals"> |
|||
<field name="name" |
|||
filter_domain="['|', ('name', 'ilike', self), ('ref', 'ilike', self)]" |
|||
string="Name"/> |
|||
<field name="species_id"/> |
|||
<field name="breed_id"/> |
|||
<field name="color_id"/> |
|||
<field name="size"/> |
|||
<separator/> |
|||
<filter string="Female" |
|||
domain="[('gender', '=', 'female')]" |
|||
name="female"/> |
|||
<filter string="Male" |
|||
domain="[('gender', '=', 'male')]" |
|||
name="male"/> |
|||
<filter string="Hermaphrodite" |
|||
domain="[('gender', '=', 'hermaphrodite')]" |
|||
name="hermaphrodite"/> |
|||
<filter string="Neutered" |
|||
domain="[('gender', '=', 'neutered')]" |
|||
name="neutered"/> |
|||
<separator/> |
|||
<group expand="0" string="Group By"> |
|||
<filter name="gender" string="Gender" domain="" |
|||
context="{'group_by': 'gender'}"/> |
|||
<filter name="species_id" string="Species" domain="" |
|||
context="{'group_by': 'species_id'}"/> |
|||
<filter name="breed_id" string="Breed" domain="" |
|||
context="{'group_by': 'breed_id'}"/> |
|||
<filter name="color_id" string="Color" domain="" |
|||
context="{'group_by': 'color_id'}"/> |
|||
</group> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_animal" model="ir.actions.act_window"> |
|||
<field name="name">Animals</field> |
|||
<field name="res_model">animal</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">kanban,tree,form</field> |
|||
<field name="search_view_id" ref="view_animal_search"/> |
|||
<field name="help" type="html"> |
|||
<p class="o_view_nocontent_smiling_face"> |
|||
Create an animal. |
|||
</p> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,53 @@ |
|||
<odoo> |
|||
|
|||
<!-- Animal breed Tree View --> |
|||
<record id="view_animal_breed_tree" model="ir.ui.view"> |
|||
<field name="name">view.animal.breed.tree</field> |
|||
<field name="model">animal.breed</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Breeds"> |
|||
<field name="name"/> |
|||
<field name="species_id"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Animal breed Form View --> |
|||
<record id="view_animal_breed_form" model="ir.ui.view"> |
|||
<field name="name">view.animal.breed.form</field> |
|||
<field name="model">animal.breed</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Breed"> |
|||
<header/> |
|||
<sheet> |
|||
<div class="oe_button_box" name="button_box"/> |
|||
<div class="oe_title"> |
|||
<h1> |
|||
<field name="name"/> |
|||
</h1> |
|||
</div> |
|||
<group id="main"> |
|||
<group id="left"> |
|||
<field name="species_id"/> |
|||
</group> |
|||
<group id="right"/> |
|||
</group> |
|||
<notebook/> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_animal_breed" model="ir.actions.act_window"> |
|||
<field name="name">Breeds</field> |
|||
<field name="res_model">animal.breed</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="help" type="html"> |
|||
<p class="o_view_nocontent_smiling_face"> |
|||
Create a breed. |
|||
</p> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,55 @@ |
|||
<odoo> |
|||
|
|||
<!-- Animal color Tree View --> |
|||
<record id="view_animal_color_tree" model="ir.ui.view"> |
|||
<field name="name">view.animal.color.tree</field> |
|||
<field name="model">animal.color</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="colors"> |
|||
<field name="name"/> |
|||
<field name="breed_id"/> |
|||
<field name="species_id"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Animal Color Form View --> |
|||
<record id="view_animal_color_form" model="ir.ui.view"> |
|||
<field name="name">view.animal.color.form</field> |
|||
<field name="model">animal.color</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Color"> |
|||
<header/> |
|||
<sheet> |
|||
<div class="oe_button_box" name="button_box"/> |
|||
<div class="oe_title"> |
|||
<h1> |
|||
<field name="name"/> |
|||
</h1> |
|||
</div> |
|||
<group id="main"> |
|||
<group id="left"> |
|||
<field name="breed_id"/> |
|||
<field name="species_id"/> |
|||
</group> |
|||
<group id="right"/> |
|||
</group> |
|||
<notebook/> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_animal_color" model="ir.actions.act_window"> |
|||
<field name="name">Colors</field> |
|||
<field name="res_model">animal.color</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="help" type="html"> |
|||
<p class="o_view_nocontent_smiling_face"> |
|||
Create a color. |
|||
</p> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,54 @@ |
|||
<odoo> |
|||
|
|||
<!-- Animal Species Tree View --> |
|||
<record id="view_animal_species_tree" model="ir.ui.view"> |
|||
<field name="name">view.animal.species.tree</field> |
|||
<field name="model">animal.species</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Species"> |
|||
<field name="name"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Animal Species Form View --> |
|||
<record id="view_animal_species_form" model="ir.ui.view"> |
|||
<field name="name">view.animal.species.form</field> |
|||
<field name="model">animal.species</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Species"> |
|||
<header/> |
|||
<sheet> |
|||
<div class="oe_button_box" name="button_box"/> |
|||
<div class="oe_title"> |
|||
<h1> |
|||
<field name="name"/> |
|||
</h1> |
|||
</div> |
|||
<group id="main"> |
|||
<group id="left"/> |
|||
<group id="right"/> |
|||
</group> |
|||
<notebook> |
|||
<page string="Breeds" id="breeds"> |
|||
<field name="breed_ids"/> |
|||
</page> |
|||
</notebook> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_animal_species" model="ir.actions.act_window"> |
|||
<field name="name">Species</field> |
|||
<field name="res_model">animal.species</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="help" type="html"> |
|||
<p class="o_view_nocontent_smiling_face"> |
|||
Create a species. |
|||
</p> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,41 @@ |
|||
<odoo> |
|||
|
|||
<!-- Main Menu --> |
|||
<menuitem id="root" |
|||
name="Animals" |
|||
action="action_animal" |
|||
sequence="10" |
|||
web_icon="animal,static/description/icon.png"/> |
|||
<menuitem id="animal" |
|||
name="Animals" |
|||
action="action_animal" |
|||
sequence="10" |
|||
parent="root"/> |
|||
<menuitem id="config" |
|||
name="Configuration" |
|||
sequence="100" |
|||
parent="root" |
|||
groups="group_animal_manager"/> |
|||
|
|||
<!-- Configuration --> |
|||
<menuitem id="settings" |
|||
name="Settings" |
|||
sequence="10" |
|||
parent="config"/> |
|||
<menuitem id="species" |
|||
name="Species" |
|||
action="action_animal_species" |
|||
sequence="20" |
|||
parent="config"/> |
|||
<menuitem id="breed" |
|||
name="Breeds" |
|||
action="action_animal_breed" |
|||
sequence="30" |
|||
parent="config"/> |
|||
<menuitem id="color" |
|||
name="Colors" |
|||
action="action_animal_color" |
|||
sequence="40" |
|||
parent="config"/> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue