Skip to content

Commit

Permalink
[LINT]subscription_oca
Browse files Browse the repository at this point in the history
[LINT]subscription_oca

[LINT]subscription_oca
  • Loading branch information
flotho committed Jul 6, 2024
1 parent b7df602 commit e18a916
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 41 deletions.
6 changes: 5 additions & 1 deletion subscription_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Subscription management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a5b7e0d3ce65f481fcf7e2c49d76f35cf3e07e7b3d06fe49051f4c5eaaa34de4
!! source digest: sha256:34d756071fe20a703cbc859e7a7cb18a85f6f4c46423c76523860a3c28100788
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -87,6 +87,10 @@ Contributors

* Ilyas <[email protected]>

* `Mind And Go <https://mind-and-go.com>`__:

* Florent THOMAs <[email protected]>

Maintainers
~~~~~~~~~~~

Expand Down
4 changes: 1 addition & 3 deletions subscription_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"website": "https://github.com/OCA/contract",
"license": "AGPL-3",
"author": "Domatix, Odoo Community Association (OCA)",
"depends": ["sale_management",
"sales_team",
"account"],
"depends": ["sale_management", "sales_team", "account"],
"data": [
"views/product_template_views.xml",
"views/account_move_views.xml",
Expand Down
4 changes: 3 additions & 1 deletion subscription_oca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class AccountMove(models.Model):

def action_open_subscription(self):
self.ensure_one()
action = self.env["ir.actions.act_window"]._for_xml_id("subscription_oca.sale_subscription_action")
action = self.env["ir.actions.act_window"]._for_xml_id(

Check warning on line 16 in subscription_oca/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

subscription_oca/models/account_move.py#L15-L16

Added lines #L15 - L16 were not covered by tests
"subscription_oca.sale_subscription_action"
)
action = action.read()[0]
action["domain"] = [("id", "=", self.subscription_id.id)]
return action

Check warning on line 21 in subscription_oca/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

subscription_oca/models/account_move.py#L19-L21

Added lines #L19 - L21 were not covered by tests
4 changes: 1 addition & 3 deletions subscription_oca/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class Partner(models.Model):
string="Subscriptions",
)
subscription_count = fields.Integer(
required=False,
compute="_compute_subscription_count",
compute_sudo=True
required=False, compute="_compute_subscription_count", compute_sudo=True
)

def _compute_subscription_count(self):
Expand Down
17 changes: 8 additions & 9 deletions subscription_oca/models/sale_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ class SaleSubscription(models.Model):
string="Reference",
default=lambda self: self.env["ir.sequence"].next_by_code("sale.subscription"),
)
in_progress = fields.Boolean(string="In progress",
compute='_compute_status',
in_progress = fields.Boolean(
string="In progress",
compute="_compute_status",
readonly=False,
index=True,
store=True,
store=True,
copy=False,
)
recurring_rule_boundary = fields.Boolean(
Expand Down Expand Up @@ -130,14 +131,13 @@ class SaleSubscription(models.Model):
def _read_group_stage_ids(self, stages, domain, order):
stage_ids = stages.search([], order=order)
return stage_ids

def _get_default_stage_id(self):
""" Gives default stage_id """
"""Gives default stage_id"""
first_stage = self.env["sale.subscription.stage"].search(
[("type", "=", "draft")], order="sequence"
)
return first_stage[:1]


stage_id = fields.Many2one(
comodel_name="sale.subscription.stage",
Expand Down Expand Up @@ -168,7 +168,7 @@ def _get_default_stage_id(self):
comodel_name="sale.subscription.close.reason", string="Close Reason"
)
crm_team_id = fields.Many2one(comodel_name="crm.team", string="Sale team")
to_renew = fields.Boolean(default=False, string="To renew") #TODO: Seems not used
to_renew = fields.Boolean(default=False, string="To renew") # TODO: Seems not used

def cron_subscription_management(self):
today = date.today()
Expand Down Expand Up @@ -197,10 +197,9 @@ def _compute_status(self):
for record in self:
in_progress = False
if record.stage_id and record.stage_id.type == "in_progress":
in_progress = True
in_progress = True
record.in_progress = in_progress


@api.depends("sale_subscription_line_ids")
def _compute_total(self):
for record in self:
Expand Down
6 changes: 5 additions & 1 deletion subscription_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Subscription management</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a5b7e0d3ce65f481fcf7e2c49d76f35cf3e07e7b3d06fe49051f4c5eaaa34de4
!! source digest: sha256:34d756071fe20a703cbc859e7a7cb18a85f6f4c46423c76523860a3c28100788
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/16.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-16-0/contract-16-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=16.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>
Expand Down Expand Up @@ -434,6 +434,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Ilyas &lt;<a class="reference external" href="mailto:irazor147&#64;gmail.com">irazor147&#64;gmail.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://mind-and-go.com">Mind And Go</a>:<ul>
<li>Florent THOMAs &lt;<a class="reference external" href="mailto:florent.thomas&#64;mind-and-go.com">florent.thomas&#64;mind-and-go.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
5 changes: 1 addition & 4 deletions subscription_oca/tests/test_subscription_oca.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ def setUpClass(cls):
)

cls.stage = cls.env["sale.subscription.stage"].create(
{
"name": "Test Sub Stage",
"type": "in_progress"
}
{"name": "Test Sub Stage", "type": "in_progress"}
)
cls.stage_2 = cls.env["sale.subscription.stage"].create(
{
Expand Down
81 changes: 62 additions & 19 deletions subscription_oca/views/sale_subscription_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,33 @@
<field name="model">sale.subscription</field>
<field name="arch" type="xml">
<search>
<field name="name" filter_domain="['|', ('name', 'ilike', self), ('code', 'ilike', self)]"/>
<field name="commercial_partner_id" filter_domain="[
'|', ('partner_id', 'ilike', self), ('commercial_partner_id', 'ilike', self)]"/>
<separator/>
<filter string="My Subscriptions" domain="[('user_id', '=', uid)]" name="my_subscription_filter"/>
<separator/>
<filter string="Draft / Waiting" name="not_in_progress" domain="[('in_progress', '!=', True)]" />
<filter string="In progress" name="in_progress" domain="[('in_progress', '=', True)]" />
<separator/>
<field
name="name"
filter_domain="['|', ('name', 'ilike', self), ('code', 'ilike', self)]"
/>
<field
name="commercial_partner_id"
filter_domain="[
'|', ('partner_id', 'ilike', self), ('commercial_partner_id', 'ilike', self)]"
/>
<separator />
<filter
string="My Subscriptions"
domain="[('user_id', '=', uid)]"
name="my_subscription_filter"
/>
<separator />
<filter
string="Draft / Waiting"
name="not_in_progress"
domain="[('in_progress', '!=', True)]"
/>
<filter
string="In progress"
name="in_progress"
domain="[('in_progress', '=', True)]"
/>
<separator />
<!-- TODO: to_renew seems useless in this module -->
<field name="to_renew" />
<filter
Expand All @@ -388,10 +406,30 @@
domain="[('to_renew','=', True)]"
/>
<group expand="0" string="Group By">
<filter string="Next Recurring Date" name="group_by_recurring_next_date" domain="[]" context="{'group_by': 'recurring_next_date'}"/>
<filter string="Commercial Entity" name="group_by_commercial_partner" domain="[]" context="{'group_by': 'commercial_partner_id'}"/>
<filter string="Template" name="group_by_template" domain="[]" context="{'group_by': 'template_id'}" />
<filter string="Stage" name="group_by_stage" domain="[]" context="{'group_by': 'stage_id'}" />
<filter
string="Next Recurring Date"
name="group_by_recurring_next_date"
domain="[]"
context="{'group_by': 'recurring_next_date'}"
/>
<filter
string="Commercial Entity"
name="group_by_commercial_partner"
domain="[]"
context="{'group_by': 'commercial_partner_id'}"
/>
<filter
string="Template"
name="group_by_template"
domain="[]"
context="{'group_by': 'template_id'}"
/>
<filter
string="Stage"
name="group_by_stage"
domain="[]"
context="{'group_by': 'stage_id'}"
/>
</group>
</search>
</field>
Expand Down Expand Up @@ -433,20 +471,25 @@
<field name="res_model">sale.subscription</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{'search_default_in_progress': 1}</field>

</record>

<record id="sale_subscription_move_out_invoice_action" model="ir.actions.act_window">
<record
id="sale_subscription_move_out_invoice_action"
model="ir.actions.act_window"
>
<field name="name">Subscription Invoices</field>
<field name="res_model">account.move</field>
<field name="view_mode">tree,kanban,form</field>
<field name="view_id" ref="account.view_out_invoice_tree"/>
<field name="search_view_id" ref="account.view_account_invoice_filter"/>
<field name="domain">[('move_type', '=', 'out_invoice'), ('subscription_id', '!=', False) ]</field>
<field name="view_id" ref="account.view_out_invoice_tree" />
<field name="search_view_id" ref="account.view_account_invoice_filter" />
<field
name="domain"
>[('move_type', '=', 'out_invoice'), ('subscription_id', '!=', False) ]</field>
<field name="context">{'default_move_type': 'out_invoice'}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Get customer invoices only generated by subscriptions
Get customer invoices only generated by subscriptions
</p>
</field>
</record>
Expand Down

0 comments on commit e18a916

Please sign in to comment.