Skip to content

Commit

Permalink
[IMP] sign_oca: various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Aug 10, 2023
1 parent 20ae772 commit a8c998a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
9 changes: 8 additions & 1 deletion sign_oca/models/sign_oca_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class SignOcaTemplate(models.Model):
data = fields.Binary(attachment=True, required=True)
filename = fields.Char()
item_ids = fields.One2many("sign.oca.template.item", inverse_name="template_id")
request_count = fields.Integer(compute="_compute_request_count")
request_ids = fields.One2many("sign.oca.request", inverse_name="template_id")

@api.depends("request_ids")
def _compute_request_count(self):
for record in self:
record.request_count = len(record.request_ids)

def configure(self):
self.ensure_one()
Expand Down Expand Up @@ -69,7 +76,7 @@ class SignOcaTemplateItem(models.Model):
role_id = fields.Many2one("sign.oca.role", default=lambda r: r._get_default_role())
required = fields.Boolean()
# If no role, it will be editable by everyone...
page = fields.Integer(required=True)
page = fields.Integer(required=True, default=1)
position_x = fields.Float(required=True)
position_y = fields.Float(required=True)
width = fields.Float()
Expand Down
8 changes: 8 additions & 0 deletions sign_oca/views/sign_oca_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@
<field name="context">{}</field>
</record>

<record model="ir.actions.act_window" id="sign_oca_request_template_act_window">
<field name="name">Sign Requests</field>
<field name="res_model">sign.oca.request</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[('template_id', '=', active_id)]</field>
<field name="context">{}</field>
</record>

<record model="ir.ui.menu" id="sign_oca_request_menu">
<field name="name">Requests</field>
<field name="parent_id" ref="sign_oca_root_menu" />
Expand Down
13 changes: 12 additions & 1 deletion sign_oca/views/sign_oca_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@
icon="fa-wrench"
string="Configure"
/>
<button
name="%(sign_oca.sign_oca_request_template_act_window)s"
type="action"
icon="fa-file-text-o"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field
name="request_count"
/> Requests</span>
</div>
</button>
<button
name="%(sign_oca_template_generate_act_window)s"
type="action"
string="Send to sign"
icon="fa-paint-brush"
icon="fa-paper-plane"
/>
</div>
<group>
Expand Down

0 comments on commit a8c998a

Please sign in to comment.