Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 34 additions & 23 deletions subscription_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Subscription management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ea96c858a40ee527d0e32ee03859918c082521f205ccc1cb26e96cb3bef27800
!! source digest: sha256:1d7163cf2d7da35b3460a208800f960258c0e321470ab537d8aee3c7dfa6197e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -74,21 +74,32 @@ To create subscriptions with the sale of a product:

Invoice and delivery addresses:

- Each subscription has an *Invoice address* and a *Delivery address*.
They default to the customer's corresponding addresses and can be
overridden per subscription.
- These addresses are propagated to the recurring invoices (the invoice
is addressed to the invoice address and records the delivery one) and
to the sale orders generated by the subscription.
- The fields are shown when the *Customer Addresses* setting (group
*Display Delivery / Invoice addresses*) is enabled.
- Each subscription has an *Invoice address* and a *Delivery address*.
They default to the customer's corresponding addresses and can be
overridden per subscription.
- These addresses are propagated to the recurring invoices (the invoice
is addressed to the invoice address and records the delivery one) and
to the sale orders generated by the subscription.
- The fields are shown when the *Customer Addresses* setting (group
*Display Delivery / Invoice addresses*) is enabled.

To change the customer of one or several subscriptions:

1. Select the subscriptions in the list (or open one) and use the
*Change customer* action.
2. Pick the new customer. Optionally reapply the customer's sale
pricelist and recompute the fiscal position.
3. The change applies to the subscription and to its **future** invoices
and orders. Invoices already issued are **not** reassigned, so the
fiscal trail of posted documents is preserved. Closed subscriptions
cannot be changed.

Known issues / Roadmap
======================

- Refactor all the onchanges that have business logic to computed
write-able fields when possible. Keep onchanges only for UI purposes.
- Add tests.
- Refactor all the onchanges that have business logic to computed
write-able fields when possible. Keep onchanges only for UI purposes.
- Add tests.

Bug Tracker
===========
Expand All @@ -112,22 +123,22 @@ Authors
Contributors
------------

- Carlos Martínez <carlos@domatix.com>
- Carolina Ferrer <carolina@domatix.com>
- `Ooops404 <https://www.ooops404.com>`__:
- Carlos Martínez <carlos@domatix.com>
- Carolina Ferrer <carolina@domatix.com>
- `Ooops404 <https://www.ooops404.com>`__:

- Ilyas <irazor147@gmail.com>
- Ilyas <irazor147@gmail.com>

- `Sygel <https://www.sygel.es>`__:
- `Sygel <https://www.sygel.es>`__:

- Harald Panten
- Valentin Vinagre
- Alberto Martínez
- Harald Panten
- Valentin Vinagre
- Alberto Martínez

- Dennis Sluijk <d.sluijk@onestein.nl>
- `IKU Solutions <https://www.iku.solutions>`__:
- Dennis Sluijk <d.sluijk@onestein.nl>
- `IKU Solutions <https://www.iku.solutions>`__:

- Yan Chirino <yan.chirino@iku.solutions>
- Yan Chirino <yan.chirino@iku.solutions>

Maintainers
-----------
Expand Down
1 change: 1 addition & 0 deletions subscription_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"data/ir_cron.xml",
"data/sale_subscription_data.xml",
"wizard/close_subscription_wizard.xml",
"wizard/sale_subscription_change_partner_wizard.xml",
"security/subscription_security.xml",
"security/ir.model.access.csv",
],
Expand Down
18 changes: 14 additions & 4 deletions subscription_oca/models/sale_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,24 @@ def _compute_partner_address_ids(self):
def onchange_partner_id(self):
self.pricelist_id = self.partner_id.property_product_pricelist

@api.onchange("partner_id", "company_id")
def onchange_partner_id_fpos(self):
self.fiscal_position_id = (
def _get_fiscal_position_from_partner(self, partner=None):
"""Return the fiscal position computed from a partner and the
subscription company. Plain method so it can be reused outside the
onchange UI flow (e.g. the change-customer wizard) without relying on
onchange side effects for persistence. Defaults to the current
partner when none is provided."""
self.ensure_one()
partner = partner or self.partner_id
return (
self.env["account.fiscal.position"]
.with_company(self.company_id)
._get_fiscal_position(self.partner_id)
._get_fiscal_position(partner)
)

@api.onchange("partner_id", "company_id")
def onchange_partner_id_fpos(self):
self.fiscal_position_id = self._get_fiscal_position_from_partner()

def action_start_subscription(self):
self.close_reason_id = False
in_progress_stage = self.env["sale.subscription.stage"].search(
Expand Down
11 changes: 11 additions & 0 deletions subscription_oca/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ Invoice and delivery addresses:
to the sale orders generated by the subscription.
- The fields are shown when the *Customer Addresses* setting
(group *Display Delivery / Invoice addresses*) is enabled.

To change the customer of one or several subscriptions:

1. Select the subscriptions in the list (or open one) and use the
*Change customer* action.
2. Pick the new customer. Optionally reapply the customer's sale
pricelist and recompute the fiscal position.
3. The change applies to the subscription and to its **future**
invoices and orders. Invoices already issued are **not** reassigned,
so the fiscal trail of posted documents is preserved. Closed
subscriptions cannot be changed.
1 change: 1 addition & 0 deletions subscription_oca/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ access_custom_sale_subscription_stage,sale.subscription.stage,model_sale_subscri
access_custom_sale_subscription_line,sale.subscription.line,model_sale_subscription_line,sales_team.group_sale_salesman,1,1,1,1
access_custom_sale_subscription_tag,sale.subscription.tag,model_sale_subscription_tag,sales_team.group_sale_salesman,1,1,1,1
access_close_subscription,Close subscription access,model_close_reason_wizard,sales_team.group_sale_salesman,1,1,1,1
access_change_partner_wizard,Change partner wizard access,model_sale_subscription_change_partner_wizard,sales_team.group_sale_manager,1,1,1,1
13 changes: 12 additions & 1 deletion subscription_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Subscription management</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ea96c858a40ee527d0e32ee03859918c082521f205ccc1cb26e96cb3bef27800
!! source digest: sha256:1d7163cf2d7da35b3460a208800f960258c0e321470ab537d8aee3c7dfa6197e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/19.0/subscription_oca"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-19-0/contract-19-0-subscription_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows creating subscriptions that generate recurring
Expand Down Expand Up @@ -433,6 +433,17 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<li>The fields are shown when the <em>Customer Addresses</em> setting (group
<em>Display Delivery / Invoice addresses</em>) is enabled.</li>
</ul>
<p>To change the customer of one or several subscriptions:</p>
<ol class="arabic simple">
<li>Select the subscriptions in the list (or open one) and use the
<em>Change customer</em> action.</li>
<li>Pick the new customer. Optionally reapply the customer’s sale
pricelist and recompute the fiscal position.</li>
<li>The change applies to the subscription and to its <strong>future</strong> invoices
and orders. Invoices already issued are <strong>not</strong> reassigned, so the
fiscal trail of posted documents is preserved. Closed subscriptions
cannot be changed.</li>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
Expand Down
1 change: 1 addition & 0 deletions subscription_oca/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from . import test_subscription_security
from . import test_subscription_recurrence_dates
from . import test_subscription_partner_addresses
from . import test_subscription_change_partner
Loading
Loading