Merge PR #1060 into 14.0

Signed-off-by aleuffre
This commit is contained in:
OCA-git-bot
2024-03-19 13:11:22 +00:00
8 changed files with 43 additions and 4 deletions

View File

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

View File

@@ -3,7 +3,7 @@
{
"name": "Subscription management",
"summary": "Generate recurring invoices.",
"version": "14.0.1.3.0",
"version": "14.0.2.0.0",
"development_status": "Beta",
"category": "Subscription Management",
"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")
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

@@ -265,14 +265,22 @@ class SaleSubscription(models.Model):
def _prepare_sale_order(self, line_ids=False):
self.ensure_one()
company = self.company_id
# Fix for multi-company issue with team_id
# Cannot assign team belonging to a different company
team_id = self.env["sale.order"]._get_default_team()
if team_id.company_id and team_id.company_id != company:
team_id = False
return {
"partner_id": self.partner_id.id,
"company_id": company.id,
"fiscal_position_id": self.fiscal_position_id.id,
"date_order": datetime.now(),
"payment_term_id": self.partner_id.property_payment_term_id.id,
"user_id": self.user_id.id,
"origin": self.name,
"order_line": line_ids,
"team_id": team_id and team_id.id or False,
}
def _prepare_account_move(self, line_ids):

View File

@@ -46,6 +46,7 @@ class SaleSubscriptionTemplate(models.Model):
company_id = fields.Many2one(
"res.company",
"Company",
required=True,
default=lambda self: self.env.company,
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">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -366,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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>This module allows creating subscriptions that generate recurring invoices or orders. It also enables the sale of products that generate subscriptions.</p>