diff --git a/partner_route/README.rst b/partner_route/README.rst new file mode 100644 index 000000000..dda23d2f8 --- /dev/null +++ b/partner_route/README.rst @@ -0,0 +1,101 @@ +============== +Partner Routes +============== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/12.0/partner_route + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-partner_route + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/167/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module serves as a baseline to define the partner routes that the members +of an organization need to do to acomplish a task over customers regularly + +For example: + + - Commercial routes. + - Delivery routes. + - Salesmen routes. + - Repair routes. + +The module comes without any of this specific capacities, that should be further +developed. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To make a route: + +#. Go to *Contacts > Configuration > Partner Routes* +#. Create a new one. You can set: + + - A user responsible for the route. + - The periodicy: daily, weekly, monthly, yearly. + - How many periods to count. + - Set the next date in wich the route must be done. + - A route type which is only informative withot extension modules. +#. Now, add partners and sort them in the order the visits will be done. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * David Vidal + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_route/__init__.py b/partner_route/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_route/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_route/__manifest__.py b/partner_route/__manifest__.py new file mode 100644 index 000000000..08ba03200 --- /dev/null +++ b/partner_route/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Partner Routes", + "summary": "Base module to assign routes to partners", + "version": "12.0.1.0.0", + "category": "Customer Relationship Management", + "website": "https://github.com/OCA/partner-contact", + "author": "Tecnativa," + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["contacts"], + "data": [ + "security/res_groups.xml", + "security/ir.model.access.csv", + "views/partner_route_view.xml", + ], + "installable": True, +} diff --git a/partner_route/models/__init__.py b/partner_route/models/__init__.py new file mode 100644 index 000000000..5819d7b53 --- /dev/null +++ b/partner_route/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_partner +from . import partner_route diff --git a/partner_route/models/partner_route.py b/partner_route/models/partner_route.py new file mode 100644 index 000000000..78b62d686 --- /dev/null +++ b/partner_route/models/partner_route.py @@ -0,0 +1,100 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html +from odoo import api, fields, models +from dateutil.relativedelta import relativedelta + + +class PartnerRoute(models.Model): + _name = "partner.route" + _description = "Partner Routes" + _inherit = ['mail.thread', 'mail.activity.mixin'] + + name = fields.Char(required=True) + active = fields.Boolean(default=True) + user_id = fields.Many2one( + comodel_name="res.users", + string="Responsible", + help="Which user is in charge of the route", + ) + route_type = fields.Selection( + selection=[ + ("crm", "CRM"), + ("sale", "Sales"), + ("delivery", "Delivery"), + ("repair", "Repair"), + ], + ) + interval_unit = fields.Selection( + string="Interval", + selection=[ + ("days", "Day(s)"), + ("weeks", "Week(s)"), + ("months", "Month(s)"), + ("years", "Year(s)"), + ], + default="weeks", + required=True, + ) + recurring_interval = fields.Integer( + string="Repeat Every", + required=True, + default=1, + ) + next_date = fields.Date( + string="Next route date", + compute="_compute_next_date", + required=True, + readonly=False, + store=True, + default=fields.Date.today(), + ) + route_day = fields.Boolean( + string="Applies today", + compute="_compute_route_day", + readonly=True, + ) + route_partner_ids = fields.One2many( + comodel_name="partner.route.item", + inverse_name="route_id", + string="Partners", + ) + + @api.depends("interval_unit", "recurring_interval") + def _compute_next_date(self): + if self.next_date == fields.Date.today(): + return + delta = relativedelta(**{self.interval_unit: self.recurring_interval}) + self.next_date = fields.Date.today() + delta + + @api.depends("next_date") + def _compute_route_day(self): + self.route_day = self.next_date == fields.Date.today() + + +class PartnerRouteItem(models.Model): + _name = "partner.route.item" + _description = "Route Partners" + _order = "sequence, partner_id" + + sequence = fields.Integer() + route_id = fields.Many2one( + comodel_name="partner.route", + ) + partner_id = fields.Many2one( + comodel_name="res.partner", + ) + street = fields.Char( + related="partner_id.street", + ) + city = fields.Char( + related="partner_id.city", + ) + zip = fields.Char( + related="partner_id.zip", + ) + state_id = fields.Many2one( + related="partner_id.state_id", + ) + country_id = fields.Many2one( + related="partner_id.country_id", + ) diff --git a/partner_route/models/res_partner.py b/partner_route/models/res_partner.py new file mode 100644 index 000000000..f73654d48 --- /dev/null +++ b/partner_route/models/res_partner.py @@ -0,0 +1,12 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + route_ids = fields.One2many( + comodel_name="partner.route.item", + inverse_name="partner_id", + ) diff --git a/partner_route/readme/CONTRIBUTORS.rst b/partner_route/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..94b6ba953 --- /dev/null +++ b/partner_route/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + + * David Vidal diff --git a/partner_route/readme/DESCRIPTION.rst b/partner_route/readme/DESCRIPTION.rst new file mode 100644 index 000000000..bc58be6cd --- /dev/null +++ b/partner_route/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +This module serves as a baseline to define the partner routes that the members +of an organization need to do to acomplish a task over customers regularly + +For example: + + - Commercial routes. + - Delivery routes. + - Salesmen routes. + - Repair routes. + +The module comes without any of this specific capacities, that should be further +developed. diff --git a/partner_route/readme/USAGE.rst b/partner_route/readme/USAGE.rst new file mode 100644 index 000000000..786e0943d --- /dev/null +++ b/partner_route/readme/USAGE.rst @@ -0,0 +1,11 @@ +To make a route: + +#. Go to *Contacts > Configuration > Partner Routes* +#. Create a new one. You can set: + + - A user responsible for the route. + - The periodicy: daily, weekly, monthly, yearly. + - How many periods to count. + - Set the next date in wich the route must be done. + - A route type which is only informative withot extension modules. +#. Now, add partners and sort them in the order the visits will be done. diff --git a/partner_route/security/ir.model.access.csv b/partner_route/security/ir.model.access.csv new file mode 100644 index 000000000..4a268fcb2 --- /dev/null +++ b/partner_route/security/ir.model.access.csv @@ -0,0 +1,6 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_partner_route_group_user","partner_route group_user","model_partner_route","base.group_user",1,0,0,0 +"access_partner_route_group_route_user","partner_route group_system","model_partner_route","partner_route_group_user",1,1,0,0 +"access_partner_route_group_route_manager","partner_route group_system","model_partner_route","partner_route_group_manager",1,1,1,1 +"access_partner_route_item_group_user","partner_route group_user","model_partner_route_item","base.group_user",1,0,0,0 +"access_partner_route_item_group_route_user","partner_route group_system","model_partner_route_item","partner_route_group_user",1,1,1,1 diff --git a/partner_route/security/res_groups.xml b/partner_route/security/res_groups.xml new file mode 100755 index 000000000..da2214126 --- /dev/null +++ b/partner_route/security/res_groups.xml @@ -0,0 +1,23 @@ + + + + + Partner Routes + Manage Partner Routes + + + + User + the user can edit the route but cannot create or delete them. + + + + + Manager + the user can create and remove routes. + + + + + diff --git a/partner_route/static/description/index.html b/partner_route/static/description/index.html new file mode 100644 index 000000000..e72748993 --- /dev/null +++ b/partner_route/static/description/index.html @@ -0,0 +1,451 @@ + + + + + + +Partner Routes + + + +
+

Partner Routes

+ + +

Beta License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runbot

+

This module serves as a baseline to define the partner routes that the members +of an organization need to do to acomplish a task over customers regularly

+

For example:

+
+
    +
  • Commercial routes.
  • +
  • Delivery routes.
  • +
  • Salesmen routes.
  • +
  • Repair routes.
  • +
+
+

The module comes without any of this specific capacities, that should be further +developed.

+

Table of contents

+ +
+

Usage

+

To make a route:

+
    +
  1. Go to Contacts > Configuration > Partner Routes
  2. +
  3. Create a new one. You can set:
      +
    • A user responsible for the route.
    • +
    • The periodicy: daily, weekly, monthly, yearly.
    • +
    • How many periods to count.
    • +
    • Set the next date in wich the route must be done.
    • +
    • A route type which is only informative withot extension modules.
    • +
    +
  4. +
  5. Now, add partners and sort them in the order the visits will be done.
  6. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/sale-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/partner_route/views/partner_route_view.xml b/partner_route/views/partner_route_view.xml new file mode 100755 index 000000000..9f94f113d --- /dev/null +++ b/partner_route/views/partner_route_view.xml @@ -0,0 +1,95 @@ + + + + + partner.route + + + + + + + + + partner.route + +
+ +
+ +
+
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+
+
+ + Partner Routes + ir.actions.act_window + partner.route + form + tree,form,pivot,activity + [] + + +