diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-09-01 17:04:28 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-09-01 17:04:28 +0700 |
| commit | b4cb2913b26644f11abc6f9ea73912a6d3072918 (patch) | |
| tree | ace7cbb56fb78381c975c97e6885671b99474e30 | |
| parent | 645b385f1feea20975f1abaacdf6ffdcb0af7ff1 (diff) | |
Faktur Pajak di Internal Use
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 29 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 11 |
2 files changed, 38 insertions, 2 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 9b5f0036..5142bc5f 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -3,10 +3,35 @@ from odoo import fields, models, api class StockPicking(models.Model): _inherit = 'stock.picking' - is_internal_use = fields.Boolean('Internal Use', help="flag which is internal use or not") - account_id = fields.Many2one('account.account', string="Account") + is_internal_use = fields.Boolean('Internal Use', help='flag which is internal use or not') + account_id = fields.Many2one('account.account', string='Account') + efaktur_id = fields.Many2one('vit.efaktur', string='Faktur Pajak') + is_efaktur_exported = fields.Boolean(string='Is eFaktur Exported') + date_efaktur_exported = fields.Datetime(string='eFaktur Exported Date') @api.onchange('picking_type_id') def _onchange_operation_type(self): self.is_internal_use = self.picking_type_id.is_internal_use return + + @api.model + def create(self, vals): + self._use_faktur(vals) + return super(StockPicking, self).create(vals) + + def write(self, vals): + self._use_faktur(vals) + return super(StockPicking, self).write(vals) + + def _use_faktur(self, vals): + if vals.get('efaktur_id', False): + self.env['vit.efaktur'].search( + [ + ('id', '=', vals['efaktur_id']) + ], + limit=1 + ).is_used = True + + if self.efaktur_id.id != vals['efaktur_id']: + self.efaktur_id.is_used = False + return True diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 9081a58e..0a8dba0b 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -23,6 +23,17 @@ }" /> </field> + <page name="note" position="after"> + <page string="E-Faktur" name="efaktur" attrs="{'invisible': [['is_internal_use', '=', False]]}"> + <group> + <group> + <field name="efaktur_id" domain="[('is_used','=',False)]"/> + <field name="is_efaktur_exported"/> + <field name="date_efaktur_exported"/> + </group> + </group> + </page> + </page> </field> </record> </data> |
