diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-09-10 10:27:15 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-09-10 10:27:15 +0700 |
| commit | ee22bb5c668c346c5f8ba2c4e148324dab0c6a3e (patch) | |
| tree | 938af8b592ff555c6911924ebaf4335f3379b20c | |
| parent | 494acce1cb7490ab27ad06d2bb9f36d98fbb2256 (diff) | |
bill dp
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 47 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 4 |
2 files changed, 51 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 8ec904a9..83e401b7 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -66,6 +66,53 @@ class PurchaseOrder(models.Model): ('printed', 'Printed') ], string='Printed?', copy=False, tracking=True) date_done_picking = fields.Datetime(string='Date Done Picking', compute='get_date_done') + bills_dp_id = fields.Many2one('account.move', string='Bills DP') + + def create_bill_dp(self): + if not self.env.user.is_accounting: + raise UserError('Hanya Accounting yang bisa bikin bill dp') + + current_date = datetime.utcnow() + data_bills = { + 'partner_id': self.partner_id.id, + 'partner_shipping_id': self.partner_id.id, + 'ref': self.name, + 'invoice_date': current_date, + 'date': current_date, + 'move_type': 'in_invoice' + + } + + bills = self.env['account.move'].create([data_bills]) + + product_dp = self.env['product.product'].browse(229625) + + data_line_bills = { + 'move_id': bills.id, + 'product_id': product_dp.id, #product down payment + 'account_id': 401, #Uang Muka persediaan barang dagang + 'quantity': 1, + 'product_uom_id': 1, + 'tax_ids': [line[0].taxes_id.id for line in self.order_line], + } + + + bills_line = self.env['account.move.line'].create([data_line_bills]) + + self.bills_dp_id = bills.id + + move_line = bills.line_ids + move_line.name = '[IT.121456] Down Payment' + move_line.partner_id = self.partner_id.id + + return { + 'name': _('Account Move'), + 'view_mode': 'tree,form', + 'res_model': 'account.move', + 'target': 'current', + 'type': 'ir.actions.act_window', + 'domain': [('id', '=', bills.id)] + } def get_date_done(self): picking = self.env['stock.picking'].search([ diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index c301f3d3..9ded8308 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -26,6 +26,9 @@ <button name="button_unlock" position="after"> <button name="delete_line" type="object" string="Delete " states="draft"/> </button> + <button name="button_unlock" position="after"> + <button name="create_bill_dp" string="Create Bill DP" type="object" class="oe_highlight" context="{'create_bill':True}" attrs="{'invisible': ['|', ('state', 'not in', ('purchase', 'done')), ('invoice_status', 'in', ('no', 'invoiced'))]}"/> + </button> <field name="date_order" position="before"> <field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/> <field name="sale_order"/> @@ -88,6 +91,7 @@ <field name="from_apo"/> <field name="approval_edit_line"/> <field name="logbook_bill_id"/> + <field name="bills_dp_id" readonly="1"/> </field> <field name="order_line" position="attributes"> |
