diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-03-06 10:40:10 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-03-06 10:40:10 +0700 |
| commit | d569804844ee77f9f08879dda8c3f1e292470813 (patch) | |
| tree | be8357933ccd751700cbecd00b92c30100b25e7f /indoteknik_custom | |
| parent | f53312f3f2c78d50d838c249a8d0eb1ed1e5b7f2 (diff) | |
Add action web approve on sale order, approval_step on get so api, role aliases on login
Diffstat (limited to 'indoteknik_custom')
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 15 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 988f13c8..6fe1db3b 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -636,7 +636,20 @@ class SaleOrder(models.Model): line.discount = line.initial_discount line.initial_discount = False - + def action_web_approve(self): + if self.env.uid != self.partner_id.user_id.id: + raise UserError('You are not authorized to approve this order. Only %s can approve this order.' % self.partner_id.user_id.name) + + self.web_approval = 'company' + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Berhasil approve web order', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 8e05c2e7..8e0c9bbe 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -16,10 +16,16 @@ type="object" attrs="{'invisible': [('approval_status', 'in', ['pengajuan1', 'pengajuan2', 'approved'])]}" /> + <button name="action_web_approve" + string="Web Approve" + type="object" + attrs="{'invisible': ['|', '|', ('create_uid', '!=', 25), ('web_approval', '!=', False), ('state', '!=', 'draft')]}" + /> <button name="indoteknik_custom.action_view_uangmuka_penjualan" string="UangMuka" type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/> </button> <field name="payment_term_id" position="after"> + <field name="create_uid" invisible="1"/> <field name="create_date" invisible="1"/> <field name="shipping_cost_covered" attrs="{'required': ['|', ('create_date', '>', '2023-06-15'), ('create_date', '=', False)]}"/> <field name="shipping_paid_by" attrs="{'required': ['|', ('create_date', '>', '2023-06-15'), ('create_date', '=', False)]}"/> |
