summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-07-18 05:57:38 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-07-18 05:57:38 +0000
commitbe96aa583d6d68404a19350aae464a05a3f6efd4 (patch)
tree1f8270064b940e9df4c1359c3c20e6d8bd3f355b
parent5b1c2054e3ca176a3705c6d0a84e33867ad1c945 (diff)
parentcc4150ade5d8f6cea80ce4acf92907be0a3ed29a (diff)
Merged in receipt-bill (pull request #58)
Receipt bill
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rw-r--r--indoteknik_custom/models/bill_receipt.py95
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv2
-rw-r--r--indoteknik_custom/views/bill_receipt.xml86
-rw-r--r--indoteknik_custom/views/ir_sequence.xml10
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml1
7 files changed, 197 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 4fa736f6..f91b33d7 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -79,6 +79,7 @@
'views/landedcost.xml',
'views/product_sla.xml',
'views/voucher.xml',
+ 'views/bill_receipt.xml',
'report/report.xml',
'report/report_banner_banner.xml',
'report/report_banner_banner2.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 9e4d2cf9..8b3296a5 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -66,4 +66,5 @@ from . import requisition
from . import token_storage
from . import product_sla
from . import account_move_due_extension
-from . import voucher \ No newline at end of file
+from . import voucher
+from . import bill_receipt \ No newline at end of file
diff --git a/indoteknik_custom/models/bill_receipt.py b/indoteknik_custom/models/bill_receipt.py
new file mode 100644
index 00000000..39d5f31b
--- /dev/null
+++ b/indoteknik_custom/models/bill_receipt.py
@@ -0,0 +1,95 @@
+from odoo import models, api, fields
+from odoo.exceptions import AccessError, UserError, ValidationError
+from datetime import timedelta, date
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class BillReceipt(models.Model):
+ _name = "bill.receipt"
+ _description = "Bill Receipt"
+ _rec_name = 'number'
+
+ number = fields.Char(string='Document No', index=True, copy=False, readonly=True, tracking=True)
+ vendor_id = fields.Many2one('res.partner', string="Vendor", required=True)
+ document_date = fields.Date(string="Document Date", required=True)
+ description = fields.Text(string='Description')
+ validated = fields.Boolean(string="Validated", readonly=True)
+ bill_line = fields.One2many('bill.receipt.line', 'bill_id', string='Bill Receipt Lines')
+
+ @api.model
+ def create(self, vals):
+ vals['number'] = self.env['ir.sequence'].next_by_code('bill.receipt') or '0'
+ result = super(BillReceipt, self).create(vals)
+ return result
+
+ def validate_button(self):
+ if not self.bill_line:
+ raise UserError('Bill receipt line masih kosong')
+
+ self.validated = True
+
+ def cancel_button(self):
+ if not self.bill_line:
+ raise UserError('Bill receipt line masih kosong')
+
+ if self.validated != True:
+ raise UserError('Document ini belum di validate')
+
+ self.validated = False
+
+class BillReceiptLine(models.Model):
+ _name = 'bill.receipt.line'
+ _description = 'Bill Receipt Line'
+ _order = 'bill_id, id'
+
+ bill_id = fields.Many2one('bill.receipt', string='Bill Receipt')
+ sale_order_id = fields.Many2one('sale.order', string='Sale Order')
+ po_id = fields.Many2one('purchase.order', string='PO')
+ user_id = fields.Many2one('res.users', string='Purchase Rep')
+ payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms')
+ vendor_id = fields.Many2one('res.partner', string='Vendor')
+ date_approve = fields.Datetime(string='Confirmation Date')
+ date_planned = fields.Datetime(string='Receipt Date')
+ amount_untaxed = fields.Float(string='Untaxed Amount')
+ amount_total = fields.Float(string='Total')
+ reference = fields.Char(string='Reference')
+ partner_ref = fields.Char(string='Vendor Reference')
+
+ @api.onchange('po_id')
+ def onchange_partner_ref(self):
+ self.partner_ref = self.po_id.partner_ref
+
+ @api.onchange('po_id')
+ def onchange_vendor_id(self):
+ self.vendor_id = self.po_id.partner_id
+
+ @api.onchange('po_id')
+ def onchange_date_approve(self):
+ self.date_approve = self.po_id.date_approve
+
+ @api.onchange('po_id')
+ def onchange_date_planned(self):
+ self.date_planned = self.po_id.date_planned
+
+ @api.onchange('po_id')
+ def onchange_amount_untaxed(self):
+ self.amount_untaxed = self.po_id.amount_untaxed
+
+ @api.onchange('po_id')
+ def onchange_user_id(self):
+ self.user_id = self.po_id.user_id
+
+ @api.onchange('po_id')
+ def onchange_sale_order_id(self):
+ self.sale_order_id = self.po_id.sale_order_id
+
+ @api.onchange('po_id')
+ def onchange_payment_term_id(self):
+ self.payment_term_id = self.po_id.payment_term_id
+
+ @api.onchange('po_id')
+ def onchange_amount_total(self):
+ self.amount_total = self.po_id.amount_total
+
+
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 2b269417..379c4c8e 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -57,3 +57,5 @@ access_requisition_purchase_match,access.requisition.purchase.match,model_requis
access_token_storage,access.token_storage,model_token_storage,,1,1,1,1
access_product_sla,access.product_sla,model_product_sla,,1,1,1,1
access_voucher,access.voucher,model_voucher,,1,1,1,1
+access_bill_receipt,access.bill.receipt,model_bill_receipt,,1,1,1,1
+access_bill_receipt_line,access.bill.receipt.line,model_bill_receipt_line,,1,1,1,1
diff --git a/indoteknik_custom/views/bill_receipt.xml b/indoteknik_custom/views/bill_receipt.xml
new file mode 100644
index 00000000..cfc268b0
--- /dev/null
+++ b/indoteknik_custom/views/bill_receipt.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<odoo>
+ <record id="bill_receipt_tree" model="ir.ui.view">
+ <field name="name">bill.receipt.tree</field>
+ <field name="model">bill.receipt</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="number"/>
+ <field name="vendor_id"/>
+ <field name="document_date"/>
+ <field name="description"/>
+ <field name="validated"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="bill_receipt_line_tree" model="ir.ui.view">
+ <field name="name">bill.receipt.line.tree</field>
+ <field name="model">bill.receipt.line</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="partner_ref"/>
+ <field name="po_id"/>
+ <field name="sale_order_id"/>
+ <field name="user_id"/>
+ <field name="vendor_id"/>
+ <field name="date_approve"/>
+ <field name="date_planned"/>
+ <field name="reference"/>
+ <field name="amount_untaxed"/>
+ <field name="amount_total"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="bill_receipt_form" model="ir.ui.view">
+ <field name="name">bill.receipt.form</field>
+ <field name="model">bill.receipt</field>
+ <field name="arch" type="xml">
+ <form>
+ <header>
+ <button name="validate_button"
+ string="Validate"
+ type="object"
+ />
+ <button name="cancel_button"
+ string="Cancel"
+ type="object"
+ />
+ </header>
+ <sheet>
+ <group>
+ <group>
+ <field name="vendor_id" attrs="{'readonly': [('validated', '=', True)]}"/>
+ <field name="document_date" attrs="{'readonly': [('validated', '=', True)]}"/>
+ <field name="description" attrs="{'readonly': [('validated', '=', True)]}"/>
+ </group>
+ <group>
+ <field name="validated" readonly="1"/>
+ </group>
+ </group>
+ <notebook>
+ <page string="Bill Line" name="bill_line">
+ <field name="bill_line" attrs="{'readonly': [('validated', '=', True)]}"/>
+ </page>
+ </notebook>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="bill_receipt_action" model="ir.actions.act_window">
+ <field name="name">Bill Line</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">bill.receipt</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_bill_receipt"
+ name="Bill Line"
+ parent="sale.product_menu_catalog"
+ sequence="4"
+ action="bill_receipt_action"
+ />
+</odoo>
diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml
index a8348772..6798e5b4 100644
--- a/indoteknik_custom/views/ir_sequence.xml
+++ b/indoteknik_custom/views/ir_sequence.xml
@@ -41,6 +41,16 @@
<field name="number_increment">1</field>
</record>
+ <record id="sequence_bill_receipt" model="ir.sequence">
+ <field name="name">Bill Receipt</field>
+ <field name="code">bill.receipt</field>
+ <field name="active">TRUE</field>
+ <field name="prefix">BR/%(year)s/</field>
+ <field name="padding">5</field>
+ <field name="number_next">1</field>
+ <field name="number_increment">1</field>
+ </record>
+
<record id="sequence_requisition" model="ir.sequence">
<field name="name">Requisition</field>
<field name="code">requisition</field>
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 4efa8cf4..2f8590f3 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -32,6 +32,7 @@
<field name="date_order" position="before">
<field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
<field name="approval_status"/>
+ <field name="amount_total_without_service"/>
</field>
<field name="currency_id" position="after">
<field name="summary_qty_po"/>