forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (C) 2020 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Animal Owner", | ||
"version": "12.0.1.0.0", | ||
"license": "AGPL-3", | ||
"summary": "Add owner to the animal", | ||
"author": "Open Source Integrators, Odoo Community Association (OCA)", | ||
"maintainer": "Open Source Integrators", | ||
"website": "https://github.com/OCA/partner-contact", | ||
"depends": ["animal"], | ||
"data": ["views/animal.xml", "views/res_partner.xml"], | ||
"application": False, | ||
"development_status": "Beta", | ||
"maintainers": ["max3903"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright (C) 2020 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import animal, res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (C) 2020 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class Animal(models.Model): | ||
_inherit = "animal" | ||
|
||
partner_id = fields.Many2one( | ||
"res.partner", string="Owner", index=True, track_visibility="onchange" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 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 ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
@api.depends("animal_ids") | ||
def _compute_animal_count(self): | ||
for rec in self: | ||
rec.animal_count = len(rec.animal_ids) | ||
|
||
animal_ids = fields.One2many("animal", "partner_id", string="Animals") | ||
animal_count = fields.Integer( | ||
compute=_compute_animal_count, string="Number of Animals", store=True | ||
) | ||
|
||
@api.multi | ||
def action_view_animals(self): | ||
action = self.env.ref("animal.action_animal").read()[0] | ||
if self.animal_count > 1: | ||
action["domain"] = [("id", "in", self.animal_ids.ids)] | ||
else: | ||
action["views"] = [(self.env.ref("animal.view_animal_form").id, "form")] | ||
action["res_id"] = self.animal_ids and self.animal_ids.ids[0] or False | ||
return action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Open Source Integrators <https://www.opensourceintegrators.com> | ||
|
||
* Maxime Chambreuil <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module allows you to store the owner of a pet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Go to Animals | ||
* Create or select an animal | ||
* Select his owner |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<odoo> | ||
|
||
<!-- Animal Tree View --> | ||
<record id="view_animal_owner_tree" model="ir.ui.view"> | ||
<field name="name">view.animal.owner.tree</field> | ||
<field name="model">animal</field> | ||
<field name="inherit_id" ref="animal.view_animal_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="color_id" position="after"> | ||
<field name="partner_id"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<!-- Animal Form View --> | ||
<record id="view_animal_owner_form" model="ir.ui.view"> | ||
<field name="name">view.animal.owner.form</field> | ||
<field name="model">animal</field> | ||
<field name="inherit_id" ref="animal.view_animal_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="birth_date" position="after"> | ||
<field name="partner_id"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<!-- Animal Kanban View --> | ||
<record id="view_animal_owner_kanban" model="ir.ui.view"> | ||
<field name="name">view.animal.owner.kanban</field> | ||
<field name="model">animal</field> | ||
<field name="inherit_id" ref="animal.view_animal_kanban"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="partner_id"/> | ||
</field> | ||
<xpath expr="//div[hasclass('oe_kanban_details')]/ul" position="inside"> | ||
<li t-if="record.partner_id.raw_value"><field name="partner_id"/></li> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<!-- Animal Search View --> | ||
<record id="view_animal_owner_search" model="ir.ui.view"> | ||
<field name="name">view.animal.owner.search</field> | ||
<field name="model">animal</field> | ||
<field name="inherit_id" ref="animal.view_animal_search"/> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="partner_id"/> | ||
</field> | ||
<filter name="gender" position="before"> | ||
<filter name="partner_id" string="Owner" domain="" | ||
context="{'group_by': 'partner_id'}"/> | ||
</filter> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<odoo> | ||
|
||
<!-- Partner Form View --> | ||
<record id="view_partner_animal_owner_form" model="ir.ui.view"> | ||
<field name="name">view.partner.animal.owner.form</field> | ||
<field name="model">res.partner</field> | ||
<field name="inherit_id" ref="base.view_partner_form"/> | ||
<field name="arch" type="xml"> | ||
<button name="toggle_active" position="before"> | ||
<button class="oe_stat_button" type="object" | ||
name="action_view_animals" icon="fa-pencil-square-o" | ||
context="{'default_partner_id': id}"> | ||
<div class="o_stat_info"> | ||
<field name="animal_count" class="o_stat_value"/> | ||
<span class="o_stat_text"> Animals</span> | ||
</div> | ||
</button> | ||
</button> | ||
</field> | ||
</record> | ||
|
||
</odoo> |