Skip to content

Commit

Permalink
[UPD] ssi_service_quotation
Browse files Browse the repository at this point in the history
* Menambahkan fungsi copy term
  • Loading branch information
andhit-r committed Oct 15, 2024
1 parent c0c0ebe commit d4276f1
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions ssi_service_quotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

from . import (
models,
wizards,
)
1 change: 1 addition & 0 deletions ssi_service_quotation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"data/sequence_template_data.xml",
"data/approval_template_data.xml",
"data/policy_template_data.xml",
"wizards/copy_quotation_term_views.xml",
"views/service_quotation_views.xml",
"views/service_contract_views.xml",
],
Expand Down
1 change: 1 addition & 0 deletions ssi_service_quotation/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ access_service_quotation_fix_item_payment_term_user,service.quotation_fix_item_p
access_service_quotation_fix_item_payment_term_detail_viewer,service.quotation_fix_item_payment_term_detail - viewer,model_service_quotation_fix_item_payment_term_detail,service_quotation_viewer_group,1,0,0,0
access_service_quotation_fix_item_payment_term_detail_user,service.quotation_fix_item_payment_term_detail - user,model_service_quotation_fix_item_payment_term_detail,service_quotation_user_group,1,1,1,1
access_service_quotation_fix_item_all,service.quotation_fix_item - all,model_service_quotation_fix_item,,1,0,0,0
access_copy_quotation_term_user,copy_quotation_term - user,model_copy_quotation_term,service_quotation_user_group,1,1,1,1
6 changes: 6 additions & 0 deletions ssi_service_quotation/views/service_quotation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
<field name="amount_untaxed" />
<field name="amount_tax" />
<field name="amount_total" />
<button
name="%(copy_quotation_term_action)d"
icon="fa-files-o"
help="Copy Term"
type="action"
/>
</tree>
<form>
<group name="fix_item_2_1" colspan="4" col="2">
Expand Down
7 changes: 7 additions & 0 deletions ssi_service_quotation/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import (
copy_quotation_term,
)
52 changes: 52 additions & 0 deletions ssi_service_quotation/wizards/copy_quotation_term.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2024 OpenSynergy Indonesia
# Copyright 2024 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class CopyQuotationTerm(models.TransientModel):
_name = "copy_quotation_term"
_description = "Copy Quotation Term"

name = fields.Char(
string="Term",
required=True,
)
sequence = fields.Integer(
string="Sequence",
required=True,
default=5,
)
term_id = fields.Many2one(
string="Payment Term",
comodel_name="service.quotation_fix_item_payment_term",
required=False,
default=lambda self: self._default_term_id(),
)
set_qty = fields.Boolean(
string="Set Qty All Items",
default=False,
)
quantity = fields.Float(
string="Quanity",
default=0.0,
)

@api.model
def _default_term_id(self):
return self.env.context.get("active_id", False)

def action_confirm(self):
self.ensure_one()
new_term = self.term_id.copy(
{
"name": self.name,
"sequence": self.sequence,
}
)
new_term.detail_ids.write(
{
"uom_quantity": self.quantity,
}
)
42 changes: 42 additions & 0 deletions ssi_service_quotation/wizards/copy_quotation_term_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="copy_quotation_term_view_form" model="ir.ui.view">
<field name="name">Copy Term</field>
<field name="model">copy_quotation_term</field>
<field name="arch" type="xml">
<form>
<group name="group_1" colspan="4" col="2">
<field name="term_id" invisible="0" required="1" />
<field name="name" />
<field name="sequence" />
<field name="set_qty" widget="boolean_toggle" />
<field
name="quantity"
attrs="{'invisible':[('set_qty','=',False)], 'required': [('set_qty','=',True)]}"
/>
</group>
<footer>
<button
string="Confirm"
name="action_confirm"
type="object"
class="oe_highlight"
confirm="Are you sure?"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>

<record id="copy_quotation_term_action" model="ir.actions.act_window">
<field name="name">Copy Term</field>
<field name="res_model">copy_quotation_term</field>
<field name="view_mode">form</field>
<field name="view_id" ref="copy_quotation_term_view_form" />
<field name="target">new</field>
</record>

</odoo>

0 comments on commit d4276f1

Please sign in to comment.