Browse Source

Merge PR #1063 into 14.0

Signed-off-by dreispt
14.0
OCA-git-bot 4 years ago
parent
commit
1b58c0ee6f
  1. 92
      partner_tier_validation/README.rst
  2. 3
      partner_tier_validation/__init__.py
  3. 18
      partner_tier_validation/__manifest__.py
  4. 5
      partner_tier_validation/models/__init__.py
  5. 15
      partner_tier_validation/models/res_partner.py
  6. 58
      partner_tier_validation/models/tier_validation.py
  7. BIN
      partner_tier_validation/static/description/icon.png
  8. 109
      partner_tier_validation/views/res_partner_view.xml
  9. 1
      setup/partner_tier_validation/odoo/addons/partner_tier_validation
  10. 6
      setup/partner_tier_validation/setup.py

92
partner_tier_validation/README.rst

@ -0,0 +1,92 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
=======================
Partner Tier Validation
=======================
This module extends the functionality of Partner to support a tier
validation process.
Installation
============
This module depends on ``base_tier_validation``. You can find it at
`OCA/server-ux <https://github.com/OCA/server-ux>`_
Configuration
=============
To configure this module, you need to:
#. Go to *Settings > Technical > Tier Validations > Tier Definition*.
#. Create as many tiers as you want for Contact model.
#. Example:
Definition Formula
Tier Definition Expression
# Available locals:
# - rec: current record
[rec.state == New]
Usage
=====
To use this module, you need to:
#. Create a Contact triggering at least one "Tier Definition".
#. Click on *Request Validation* button.
#. Under the tab *Reviews* have a look to pending reviews and their statuses.
#. Validator has to update Is Customer or Is Supplier or Both for this Contact to be usable on SO/PO.
Additional features:
* You can filter the Invoices requesting your review through the filter *Needs my
Review*.
* User with rights to confirm the Vendor Bill (validate all tiers that would
be generated) can directly do the operation, this is, there is no need for
her/him to request a validation.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/142/11.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/sale-workflow/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors
------------
* Antonio Yamuta <ayamuta@opensourceintegrators.com>
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

3
partner_tier_validation/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

18
partner_tier_validation/__manifest__.py

@ -0,0 +1,18 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Partner Tier Validation",
"summary": "Extends the functionality of Contacts to"
"support a tier validation process.",
"version": "14.0.1.0.0",
"website": "https://github.com/OCA/partner-contact",
"category": "Contact",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["contacts", "base_tier_validation"],
"data": [
"views/res_partner_view.xml",
],
}

5
partner_tier_validation/models/__init__.py

@ -0,0 +1,5 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import res_partner
from . import tier_validation

15
partner_tier_validation/models/res_partner.py

@ -0,0 +1,15 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResPartner(models.Model):
_name = "res.partner"
_inherit = ["res.partner", "tier.validation", "mail.activity.mixin"]
_state_from = ["new", "to approve"]
_state_to = ["approved"]
state = fields.Selection(
[("new", "New"), ("approved", "Approved")], string="Status", default="new"
)

58
partner_tier_validation/models/tier_validation.py

@ -0,0 +1,58 @@
# Copyright 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
class TierValidation(models.AbstractModel):
_inherit = "tier.validation"
@api.model
def _get_under_validation_exceptions(self):
"""Extend for more field exceptions."""
res = super(TierValidation, self)._get_under_validation_exceptions() or []
ex_fields = ["categ_id", "state", "customer", "supplier", "excise_tax"]
for val in ex_fields:
res.append(val)
return res
def validate_tier(self):
super(TierValidation, self).validate_tier()
# make sure to only work with res.partner object.
if self._name != "res.partner":
return
for partner in self:
rec = self.env["tier.review"].search(
[("res_id", "=", partner.id), ("model", "=", "res.partner")]
)
if rec and rec.status == "approved":
partner.state = "approved"
# Need to override for Partner Tier Validation since can_review field
# is set to True based only
# if current user is a member of reviewer_ids. This can_review field
# is used to enable or disable the boolean
# field Is Customer / Is Vendor not only during the Validation process
# but even if it is in Approved State.
@api.depends("review_ids")
def _compute_reviewer_ids(self):
if str(self.__class__) == "<class 'odoo.api.res.partner'>":
for rec in self:
rec.reviewer_ids = rec.review_ids.filtered(
lambda r: r.status in ("pending", "approved")
).mapped("reviewer_ids")
else:
for rec in self:
rec.reviewer_ids = rec.review_ids.filtered(
lambda r: r.status == "pending"
).mapped("reviewer_ids")
def request_validation(self):
res = super().request_validation()
for rec in self.filtered(lambda x: x._name == "res.partner"):
rec.message_subscribe(
partner_ids=[
self.env.user.partner_id.id,
]
)
return res

BIN
partner_tier_validation/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

109
partner_tier_validation/views/res_partner_view.xml

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="partner_form_tier" model="ir.ui.view">
<field name="name">partner.form.tier</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="/form/sheet" position="before">
<header>
<field name="state" widget="statusbar" statusbar_visible="new, approved" />
<button
name="request_validation"
string="Request Validation"
attrs="{'invisible': ['|','|',('need_validation', '!=', True),('rejected','=',True),('state','not in',['new','to approve'])]}"
type="object"
/>
<button
name="restart_validation"
string="Restart Validation"
attrs="{'invisible': ['|',('review_ids', '=', []),('state','not in',['new','to approve'])]}"
type="object"
/>
</header>
</xpath>
<header position="after">
<field name="need_validation" invisible="1" />
<field name="validated" invisible="1" />
<field name="rejected" invisible="1" />
<field name="reviewer_ids" invisible="1" />
<div
class="alert alert-warning"
role="alert"
attrs="{'invisible': ['|', '|', '|',
('validated', '=', True), ('state', 'not in', ['new','to approve']),
('rejected', '=', True), ('review_ids', '=', [])]}"
style="margin-bottom:0px;"
>
<p><i class="fa fa-info-circle" />This partner needs to be
approved before it can have transactions.
<field name="can_review" invisible="1" />
<button
name="validate_tier"
string="Validate"
attrs="{'invisible': [('can_review', '=', False)]}"
type="object"
class="oe_inline oe_button btn-success"
icon="fa-thumbs-up"
/>
<button
name="reject_tier"
string="Reject"
attrs="{'invisible': [('can_review', '=', False)]}"
type="object"
class="btn-icon btn-danger"
icon="fa-thumbs-down"
/>
</p>
</div>
<div
class="alert alert-success"
role="alert"
attrs="{'invisible': ['|', '|', ('validated', '!=', True), ('state', 'not in', ['new','to approve']), ('review_ids', '=', [])]}"
style="margin-bottom:0px;"
>
<p><i class="fa fa-thumbs-up" /> Partner has been <b
>approved and now can have transactions</b>!</p>
</div>
<div
class="alert alert-danger"
role="alert"
attrs="{'invisible': ['|', '|', ('rejected', '!=', True), ('state', 'not in', ['new','to approve']), ('review_ids', '=', [])]}"
style="margin-bottom:0px;"
>
<p><i class="fa fa-thumbs-down" /> Partner creation has been <b
>rejected</b>.</p>
</div>
</header>
<xpath expr="//form/div[hasclass('oe_chatter')]" position="before">
<field
name="review_ids"
widget="tier_validation"
attrs="{'invisible':[('review_ids', '=', [])]}"
/>
</xpath>
</field>
</record>
<record id="partner_form_tier_filter" model="ir.ui.view">
<field name="name">partner.form.tier.filter</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter" />
<field name="arch" type="xml">
<filter name="type_person" position="before">
<filter
name="needs_review"
string="Needs my Review"
domain="[('reviewer_ids','in',uid), ('state', 'not in', ['approved','to approve'])]"
help="Partner(s) to review"
/>
</filter>
</field>
</record>
</odoo>

1
setup/partner_tier_validation/odoo/addons/partner_tier_validation

@ -0,0 +1 @@
../../../../partner_tier_validation

6
setup/partner_tier_validation/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save