Browse Source

Merge PR #974 into 12.0

Signed-off-by max3903
12.0
OCA-git-bot 4 years ago
parent
commit
6da650d34e
  1. 21
      animal_owner/README.rst
  2. 3
      animal_owner/__init__.py
  3. 16
      animal_owner/__manifest__.py
  4. 3
      animal_owner/models/__init__.py
  5. 11
      animal_owner/models/animal.py
  6. 27
      animal_owner/models/res_partner.py
  7. 3
      animal_owner/readme/CONTRIBUTORS.rst
  8. 1
      animal_owner/readme/DESCRIPTION.rst
  9. 3
      animal_owner/readme/USAGE.rst
  10. BIN
      animal_owner/static/description/icon.png
  11. 58
      animal_owner/views/animal.xml
  12. 22
      animal_owner/views/res_partner.xml

21
animal_owner/README.rst

@ -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.

3
animal_owner/__init__.py

@ -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

16
animal_owner/__manifest__.py

@ -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"],
}

3
animal_owner/models/__init__.py

@ -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

11
animal_owner/models/animal.py

@ -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"
)

27
animal_owner/models/res_partner.py

@ -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

3
animal_owner/readme/CONTRIBUTORS.rst

@ -0,0 +1,3 @@
* Open Source Integrators <https://www.opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>

1
animal_owner/readme/DESCRIPTION.rst

@ -0,0 +1 @@
This module allows you to store the owner of a pet.

3
animal_owner/readme/USAGE.rst

@ -0,0 +1,3 @@
* Go to Animals
* Create or select an animal
* Select his owner

BIN
animal_owner/static/description/icon.png

After

Width: 460  |  Height: 460  |  Size: 28 KiB

58
animal_owner/views/animal.xml

@ -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>

22
animal_owner/views/res_partner.xml

@ -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>
Loading…
Cancel
Save