Skip to content

Commit

Permalink
subscription_oca: Open subscription button on invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
tarteo committed Mar 14, 2024
1 parent 119ab0d commit 89c5e7a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions subscription_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"depends": ["sale_management", "account"],
"data": [
"views/product_template_views.xml",
"views/account_move_views.xml",
"views/sale_subscription_views.xml",
"views/sale_subscription_stage_views.xml",
"views/sale_subscription_tag_views.xml",
Expand Down
7 changes: 7 additions & 0 deletions subscription_oca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ class AccountMove(models.Model):
subscription_id = fields.Many2one(
comodel_name="sale.subscription", string="Subscription"
)

def action_open_subscription(self):
self.ensure_one()
action = self.env.ref("subscription_oca.sale_subscription_action")
action = action.read()[0]
action["domain"] = [("id", "=", self.subscription_id.id)]
return action
16 changes: 16 additions & 0 deletions subscription_oca/views/account_move_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<field name="subscription_id" invisible="1" />
<button name="action_open_subscription" type="object"
class="oe_stat_button" icon="fa-calendar"
string="Subscription"
attrs="{'invisible': [('subscription_id', '=', False)]}" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit 89c5e7a

Please sign in to comment.