[FIX] subscription_oca: product-subscription_template company issues

Make company required on subscription_template.

Make subcription_template_id a company-dependent field
on product_template.
This commit is contained in:
Alessandro Uffreduzzi
2024-03-15 10:37:00 +01:00
parent aca1183f80
commit 364268eaa9
7 changed files with 35 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ Subscription management
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:30f9f32f03f3354d63eec84cae0c6ecf6f3f9f02f0cc780d80b3de4c49a92eff !! source digest: sha256:ebd987588c730c485dde3b984d5da1506984ed1f42cc14a649ca24b5a54e3a4a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

View File

@@ -3,7 +3,7 @@
{ {
"name": "Subscription management", "name": "Subscription management",
"summary": "Generate recurring invoices.", "summary": "Generate recurring invoices.",
"version": "14.0.1.3.0", "version": "14.0.2.0.0",
"development_status": "Beta", "development_status": "Beta",
"category": "Subscription Management", "category": "Subscription Management",
"website": "https://github.com/OCA/contract", "website": "https://github.com/OCA/contract",

View File

@@ -0,0 +1,14 @@
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.convert_to_company_dependent(
env,
"product.template",
"old_subscription_template_id",
"subscription_template_id",
)
openupgrade.drop_columns(
env.cr, [("product_template", "old_subscription_template_id")]
)

View File

@@ -0,0 +1,13 @@
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.copy_columns(
env.cr,
{
"product_template": [
("subscription_template_id", "old_subscription_template_id", None)
]
},
)

View File

@@ -8,5 +8,7 @@ class Product(models.Model):
subscribable = fields.Boolean(string="Subscribable product") subscribable = fields.Boolean(string="Subscribable product")
subscription_template_id = fields.Many2one( subscription_template_id = fields.Many2one(
comodel_name="sale.subscription.template", string="Subscription template" comodel_name="sale.subscription.template",
string="Subscription template",
company_dependent=True,
) )

View File

@@ -46,6 +46,7 @@ class SaleSubscriptionTemplate(models.Model):
company_id = fields.Many2one( company_id = fields.Many2one(
"res.company", "res.company",
"Company", "Company",
required=True,
default=lambda self: self.env.company, default=lambda self: self.env.company,
domain=lambda self: [("id", "in", self.env.companies.ids)], domain=lambda self: [("id", "in", self.env.companies.ids)],
) )

View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
@@ -366,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:30f9f32f03f3354d63eec84cae0c6ecf6f3f9f02f0cc780d80b3de4c49a92eff !! source digest: sha256:ebd987588c730c485dde3b984d5da1506984ed1f42cc14a649ca24b5a54e3a4a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/14.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-14-0/contract-14-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=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/14.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-14-0/contract-14-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=14.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 invoices or orders. It also enables the sale of products that generate subscriptions.</p> <p>This module allows creating subscriptions that generate recurring invoices or orders. It also enables the sale of products that generate subscriptions.</p>