diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-13 09:26:37 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-13 09:26:37 +0700 |
| commit | 610b0dde2b83d539b153db5f71b68da441217eed (patch) | |
| tree | 82ba9554aa2ff0c8002f08d34d5324d5bce92d95 | |
| parent | ef05fc18109974354f7a41b2c16381614fc4b1b6 (diff) | |
feedback sj
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 28 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchasing_job.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/report_logbook_sj.py | 13 | ||||
| -rw-r--r-- | indoteknik_custom/views/report_logbook_sj.xml | 19 |
4 files changed, 40 insertions, 22 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 3eba0d62..a8a67569 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -68,7 +68,6 @@ class AutomaticPurchase(models.Model): if count > 0: raise UserError('Ada sekitar %s SO Yang sudah create PO, berikut SO nya: %s' % (count, ', '.join(names))) - def create_po_from_automatic_purchase(self): if not self.purchase_lines: raise UserError('Tidak ada Lines, belum bisa create PO') @@ -151,10 +150,35 @@ class AutomaticPurchase(models.Model): self.notification = 'PO Created successfully' self.is_po = True - + + def check_qty_po(self): + for lines in self.purchase_lines: + purchasing_job = self.env['v.purchasing.job'].search([ + ('product_id', '=', lines.product_id.id) + ], limit=1) + + po = self.env['purchase.order'].search([ + ('product_id', '=', lines.product_id.id), + ('order_sales_match_line.sale_id', '=', lines.automatic_purchase_id.sales_match.sale_id), + ('state', 'not in', ['cancel']), + ('from_apo', '=', True) + ], limit=1) + + if not purchasing_job: + raise UserError('Beberapa product sudah terbuat po dan sudah terconfirm') + + for line in po.order_line: + qty_pj = po.product_qty + lines.qty_purchase + qty_outgoing_pj = po.qty_outgoing + + if qty_pj > qty_outgoing_pj: + raise UserError('Qty yang anda beli lebih dari qty outgoing') + def create_po_by_vendor(self, vendor_id): current_time = datetime.now() + self.check_qty_po() + PRODUCT_PER_PO = 20 auto_purchase_line = self.env['automatic.purchase.line'] diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index d3d95a09..5fba0a95 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -146,7 +146,7 @@ class PurchasingJob(models.Model): 'product_id': job.product_id.id, 'qty_purchase': qty_purchase, 'qty_available': qty_available, - 'partner_id': vendor_id.id, + 'partner_id': job.vendor_id.id, 'last_price': price, 'taxes_id': taxes, 'subtotal': qty_purchase * price, diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py index 33a7ccb1..f34835ae 100644 --- a/indoteknik_custom/models/report_logbook_sj.py +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -5,13 +5,16 @@ from datetime import datetime class ReportLogbookSJ(models.Model): _name = 'report.logbook.sj' + _description = "Logbook SJ" + _inherit = ['mail.thread'] + _rec_name = 'name' name = fields.Char(string='Name', default='Logbook SJ') date = fields.Datetime(string='Date Created') - date_approve = fields.Datetime(string='Date Approve') - approve_by_finance = fields.Boolean(string='Approve By Finance') - approve_by = fields.Many2one(comodel_name='res.users', string='Approve By') - created_by = fields.Many2one(comodel_name='res.users', string='Created By') + date_approve = fields.Datetime(string='Date Approve', tracking=3) + approve_by_finance = fields.Boolean(string='Approve By Finance', tracking=3) + approve_by = fields.Many2one(comodel_name='res.users', string='Approve By', tracking=3) + created_by = fields.Many2one(comodel_name='res.users', string='Created By', tracking=3) report_logbook_sj_line = fields.One2many( comodel_name='report.logbook.sj.line', inverse_name='report_logbook_sj_id', @@ -24,7 +27,7 @@ class ReportLogbookSJ(models.Model): ], default='terima_semua', string='Status', - tracking=True + tracking=True, ) @api.model diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml index 8fd2c861..8221b419 100644 --- a/indoteknik_custom/views/report_logbook_sj.xml +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -4,7 +4,7 @@ <field name="name">report.logbook.sj.tree</field> <field name="model">report.logbook.sj</field> <field name="arch" type="xml"> - <tree create="0"> + <tree create="0" delete="0"> <field name="name"/> <field name="approve_by"/> <field name="created_by"/> @@ -67,22 +67,13 @@ </page> </notebook> </sheet> + <div class="oe_chatter"> + <field name="message_follower_ids" widget="mail_followers"/> + <field name="message_ids" widget="mail_thread"/> + </div> </form> </field> </record> -<!-- - <record id="view_report_logbook_sj_filter" model="ir.ui.view"> - <field name="name">report.logbook.sj.list.select</field> - <field name="model">report.logbook.sj</field> - <field name="priority" eval="15"/> - <field name="arch" type="xml"> - <search string="Search Report Logbook SJ"> - <field name="number"/> - <field name="partner_id"/> - <field name="dunning_line" string="Invoice" filter_domain="[('dunning_line.invoice_id', 'ilike', self)]"/> - </search> - </field> - </record> --> <record id="report_logbook_sj_action" model="ir.actions.act_window"> <field name="name">Report Logbook SJ</field> |
