Metadata-Version: 2.1
Name: odoo-addon-fieldservice_subcontracting
Version: 18.0.1.0.0.2
Requires-Python: >=3.10
Requires-Dist: odoo-addon-fieldservice==18.0.*
Requires-Dist: odoo-addon-fieldservice_project==18.0.*
Requires-Dist: odoo-addon-fieldservice_stage_server_action==18.0.*
Requires-Dist: odoo-addon-fieldservice_timesheet==18.0.*
Requires-Dist: odoo==18.0.*
Summary: Auto-create Purchase Orders when FSOs are assigned to subcontractor workers
Home-page: https://github.com/OCA/field-service
License: AGPL-3
Author: Binhex, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 18.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Development Status :: 4 - Beta
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

==============================
Field Service - Subcontracting
==============================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:c2c8b77376e2eecd82b6fb67d1975b68972a43eb87342d38659938ecef0c2f8b
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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%2Ffield--service-lightgray.png?logo=github
    :target: https://github.com/OCA/field-service/tree/18.0/fieldservice_subcontracting
    :alt: OCA/field-service
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/field-service-18-0/field-service-18-0-fieldservice_subcontracting
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=18.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module integrates Field Service with Purchasing to automate the
subcontracting workflow.

It allows users to:

1. Mark subcontractor vendors on partners.
2. Configure a service product on Field Service order templates.
3. Resolve the Purchase Order vendor from the assigned worker or its
   parent company.
4. Create draft Purchase Orders for subcontracted orders.
5. Set the Purchase Order Expected Arrival from the Field Service Order
   Scheduled End.
6. Keep the Purchase Order Expected Arrival synchronized when the Field
   Service Order planned dates change.
7. Update delivered quantities from Field Service timesheets.
8. Reassign workers on orders with linked subcontract Purchase Orders.

The module uses ``fieldservice_stage_server_action`` to trigger
automation on stage transitions.

**Table of contents**

.. contents::
   :local:

Use Cases / Context
===================

1.  Field Service operations sometimes require external workers or
    companies to perform part of the service delivery.
2.  A Field Service Order can be assigned to an internal worker, an
    individual subcontractor, or an employee of a subcontractor company.
3.  The module resolves the Purchase Order vendor from the assigned
    worker: when the worker partner has a subcontractor parent company,
    that parent company receives the Purchase Order; otherwise, the
    worker partner receives it when it is marked as subcontractor.
4.  If neither the worker partner nor its parent company is marked as
    subcontractor, the worker is treated as internal and no Purchase
    Order is created.
5.  The company can create a Purchase Order for that external service
    without manually duplicating information between Field Service and
    Purchase.
6.  The Purchase Order Expected Arrival is set from the Field Service
    Order Scheduled End (``scheduled_date_end``).
7.  When the Field Service Order planned dates change, the linked
    subcontract Purchase Order Expected Arrival is updated to match the
    current Scheduled End.
8.  The Purchase Order remains under the standard Odoo purchase flow: it
    is created as a draft, reviewed and confirmed manually, and later
    billed by the vendor.
9.  Timesheet hours logged on the Field Service Order can be pushed to
    the Purchase Order line as delivered quantity.
10. Vendor bills based on received quantities can then be created with
    the correct quantity.
11. Worker reassignment is available for orders with at least one linked
    subcontract Purchase Order, even if all linked subcontract Purchase
    Orders are cancelled.
12. Worker reassignment is only available before the Field Service Order
    reaches a closed stage.

Configuration
=============

Subcontractor partner setup
---------------------------

1. Go to Contacts.
2. Open the partner linked to the Field Service worker, or the parent
   company of that partner.
3. Configure as a vendor the partner that should receive the subcontract
   Purchase Order.
4. Enable Is Subcontractor? on the relevant partner.
5. The subcontract vendor is resolved with the following priority:

   - If the worker partner has a parent company and that parent company
     is marked as Is Subcontractor?, the Purchase Order is created for
     the parent company.
   - If the previous rule does not apply and the worker partner is
     marked as Is Subcontractor?, the Purchase Order is created directly
     for the worker partner, such as an individual freelancer.
   - If neither rule applies, no Purchase Order is created because the
     worker is considered internal.

6. Configure vendor prices on the subcontracting service product for the
   partner that will receive the Purchase Order.

|Subcontractor checkbox on the contact form|

Template setup
--------------

1. Go to Field Service > Master Data > Templates.
2. Open the template that can create subcontract Purchase Orders.
3. Set the Subcontracting Service Product.
4. Use a service product that is purchased based on received quantities.
5. Configure a vendor price on the product for each resolved
   subcontractor partner that can receive a Purchase Order.
6. If vendor bills are controlled by received quantities, update the
   delivered quantity before creating the vendor bill.

|Subcontracting product on the Field Service template|

Stage automation
----------------

1. Go to Field Service > Configuration > Stages.
2. Open the stage that should create the draft Purchase Order.
3. Assign the server action FSO: Create Subcontract PO.

|Server action to create the subcontract Purchase Order|

1. Open the closing stage that should update delivered quantities.
2. Assign the server action FSO: Update Subcontract PO Delivered Qty.
3. This action copies timesheet hours to the Purchase Order delivered
   quantity.

|Server action to update subcontract delivered quantity|

.. |Subcontractor checkbox on the contact form| image:: https://raw.githubusercontent.com/OCA/field-service/18.0/fieldservice_subcontracting/static/readme/mark_subcontractor.png
.. |Subcontracting product on the Field Service template| image:: https://raw.githubusercontent.com/OCA/field-service/18.0/fieldservice_subcontracting/static/readme/template_subcontract_product.png
.. |Server action to create the subcontract Purchase Order| image:: https://raw.githubusercontent.com/OCA/field-service/18.0/fieldservice_subcontracting/static/readme/stage_create_subcontract_po_action.png
.. |Server action to update subcontract delivered quantity| image:: https://raw.githubusercontent.com/OCA/field-service/18.0/fieldservice_subcontracting/static/readme/stage_update_subcontract_po_qty_action.png

Usage
=====

Create the subcontract Purchase Order
-------------------------------------

1. Create or open a Field Service Order that uses a template configured
   for subcontracting.
2. Assign a worker.
3. Move the order to the stage configured to create the subcontract
   Purchase Order.

|Field Service Order buttons for subcontracting|

1. The module resolves the vendor before creating the Purchase Order.
2. If the worker related partner has a parent company marked as
   subcontractor, the parent company is used as the vendor.
3. Otherwise, if the worker related partner is marked as subcontractor,
   that partner is used as the vendor.
4. If neither condition applies, the worker is considered internal and
   no Purchase Order is created. The Field Service Order chatter records
   that no Purchase Order was created for an internal worker.
5. Use the Purchase Order smart button to open the generated draft
   Purchase Order.
6. Review the Purchase Order. Its Expected Arrival is set from the Field
   Service Order Scheduled End (``scheduled_date_end``).
7. Confirm the Purchase Order manually.

|Field Service Order smart button on the Purchase Order|

1. If the Purchase Order is not created, check the Field Service Order
   chatter.
2. Review the reason posted by the module.
3. Fix the missing configuration or worker data.
4. Move the order through the configured stage again if needed.

Update the Purchase Order Expected Arrival
------------------------------------------

1. Change the Field Service Order planned dates.
2. Save the Field Service Order.
3. The active subcontract Purchase Order Expected Arrival is updated
   with the current Field Service Order Scheduled End
   (``scheduled_date_end``).
4. The generated Purchase Order line expected date is updated as well,
   so the Purchase Order header keeps the same Expected Arrival.

Update delivered quantities
---------------------------

1. Log timesheet hours on the Field Service Order.
2. Move the Field Service Order to the stage configured to update
   subcontract delivered quantities.
3. The module updates the delivered quantity on the subcontract Purchase
   Order line with the total timesheet hours of the Field Service Order.
4. The ordered quantity remains unchanged after the Purchase Order is
   created.
5. Create the vendor bill after the delivered quantity has been updated
   when the product bills based on received quantities.

Reassign or cancel an order
---------------------------

1.  Use the Reassign Worker button when an order with at least one
    subcontract Purchase Order must be reassigned.
2.  The Reassign Worker button remains available even if all linked
    subcontract Purchase Orders are cancelled.
3.  The Reassign Worker button is only available while the Field Service
    Order is not in a closed stage.
4.  If the Field Service Order is already in a closed stage, move it to
    a non-closed stage before reassigning the worker, if the business
    process allows it.
5.  Select the new worker in the reassignment wizard.
6.  Confirm the wizard.
7.  The wizard cancels draft vendor bills linked to active subcontract
    Purchase Orders before cancelling those Purchase Orders.
8.  The wizard cancels active subcontract Purchase Orders.
9.  If the new worker is also a subcontractor, the module creates a new
    Purchase Order for that subcontractor.
10. To cancel a Field Service Order with active subcontract Purchase
    Orders, use the standard cancel action.
11. Choose whether to cancel only the Field Service Order or also its
    active subcontract Purchase Orders.
12. If there are posted vendor bills, manage the Purchase Orders and
    vendor bills manually before reassigning or cancelling the Field
    Service Order.

.. |Field Service Order buttons for subcontracting| image:: https://raw.githubusercontent.com/OCA/field-service/18.0/fieldservice_subcontracting/static/readme/fso_purchase_order_buttons.png
.. |Field Service Order smart button on the Purchase Order| image:: https://raw.githubusercontent.com/OCA/field-service/18.0/fieldservice_subcontracting/static/readme/purchase_order_fso_button.png

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_subcontracting%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Binhex

Contributors
------------

- `Binhex <https://www.binhex.cloud>`__:

  - Edilio Escalona Almira e.escalona@binhex.cloud

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.

.. |maintainer-edescalona| image:: https://github.com/edescalona.png?size=40px
    :target: https://github.com/edescalona
    :alt: edescalona

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-edescalona| 

This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/18.0/fieldservice_subcontracting>`_ project on GitHub.

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