diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-10-11 15:58:58 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-10-11 15:58:58 +0700 |
| commit | dae117ce9bb219557c9a4fc995e93bc4a88ea03f (patch) | |
| tree | 62f51e1c8290651606759fc8d31a2662e7878590 /indoteknik_custom | |
| parent | fd6af0fbd83042c8471c3c58ff459f52bed45938 (diff) | |
init commit
Diffstat (limited to 'indoteknik_custom')
| -rw-r--r-- | indoteknik_custom/models/sale_advance_payment_inv.py | 167 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring_detail.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/x_manufactures.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/report/report_deliveryslip2.xml | 214 | ||||
| -rw-r--r-- | indoteknik_custom/static/src/js/delivery_order.js | 44 | ||||
| -rwxr-xr-x | indoteknik_custom/views/x_manufactures.xml | 2 |
7 files changed, 431 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_advance_payment_inv.py b/indoteknik_custom/models/sale_advance_payment_inv.py new file mode 100644 index 00000000..e07d0ee0 --- /dev/null +++ b/indoteknik_custom/models/sale_advance_payment_inv.py @@ -0,0 +1,167 @@ +from odoo import models, fields +from odoo.exceptions import UserError + + +class SaleAdvancePaymentInv(models.TransientModel): + _inherit = 'sale.advance.payment.inv' + + def create_invoices(self): + sale_orders = self.env['sale.order'].browse(self._context.get('active_ids', [])) + + if self.advance_payment_method == 'delivered': + sale_orders._create_invoices(final=self.deduct_down_payments) + else: + # Create deposit product if necessary + if not self.product_id: + vals = self._prepare_deposit_product() + self.product_id = self.env['product.product'].create(vals) + self.env['ir.config_parameter'].sudo().set_param('sale.default_deposit_product_id', self.product_id.id) + + sale_line_obj = self.env['sale.order.line'] + for order in sale_orders: + amount, name = self._get_advance_details(order) + + if self.product_id.invoice_policy != 'order': + raise UserError( + _('The product used to invoice a down payment should have an invoice policy set to "Ordered quantities". Please update your deposit product to be able to create a deposit invoice.')) + if self.product_id.type != 'service': + raise UserError( + _("The product used to invoice a down payment should be of type 'Service'. Please use another product or update this product.")) + taxes = self.product_id.taxes_id.filtered( + lambda r: not order.company_id or r.company_id == order.company_id) + tax_ids = order.fiscal_position_id.map_tax(taxes, self.product_id, order.partner_shipping_id).ids + analytic_tag_ids = [] + for line in order.order_line: + analytic_tag_ids = [(4, analytic_tag.id, None) for analytic_tag in line.analytic_tag_ids] + + so_line_values = self._prepare_so_line(order, analytic_tag_ids, tax_ids, amount) + so_line = sale_line_obj.create(so_line_values) + self._create_invoice(order, so_line, amount) + if self._context.get('open_invoices', False): + return sale_orders.action_view_invoice() + return {'type': 'ir.actions.act_window_close'} + + # def _create_invoices(self, grouped=False, final=False, date=None): + # """ + # Create the invoice associated to the SO. + # :param grouped: if True, invoices are grouped by SO id. If False, invoices are grouped by + # (partner_invoice_id, currency) + # :param final: if True, refunds will be generated if necessary + # :returns: list of created invoices + # """ + # if not self.env['account.move'].check_access_rights('create', False): + # try: + # self.check_access_rights('write') + # self.check_access_rule('write') + # except AccessError: + # return self.env['account.move'] + # + # # 1) Create invoices. + # invoice_vals_list = [] + # invoice_item_sequence = 0 # Incremental sequencing to keep the lines order on the invoice. + # for order in self: + # order = order.with_company(order.company_id) + # current_section_vals = None + # down_payments = order.env['sale.order.line'] + # + # invoice_vals = order._prepare_invoice() + # invoiceable_lines = order._get_invoiceable_lines(final) + # + # if not any(not line.display_type for line in invoiceable_lines): + # continue + # + # invoice_line_vals = [] + # down_payment_section_added = False + # for line in invoiceable_lines: + # if not down_payment_section_added and line.is_downpayment: + # # Create a dedicated section for the down payments + # # (put at the end of the invoiceable_lines) + # invoice_line_vals.append( + # (0, 0, order._prepare_down_payment_section_line( + # sequence=invoice_item_sequence, + # )), + # ) + # down_payment_section_added = True + # invoice_item_sequence += 1 + # invoice_line_vals.append( + # (0, 0, line._prepare_invoice_line( + # sequence=invoice_item_sequence, + # )), + # ) + # invoice_item_sequence += 1 + # + # invoice_vals['invoice_line_ids'] += invoice_line_vals + # invoice_vals_list.append(invoice_vals) + # + # if not invoice_vals_list: + # raise self._nothing_to_invoice_error() + # + # # 2) Manage 'grouped' parameter: group by (partner_id, currency_id). + # if not grouped: + # new_invoice_vals_list = [] + # invoice_grouping_keys = self._get_invoice_grouping_keys() + # invoice_vals_list = sorted(invoice_vals_list, key=lambda x: [x.get(grouping_key) for grouping_key in invoice_grouping_keys]) + # for grouping_keys, invoices in groupby(invoice_vals_list, key=lambda x: [x.get(grouping_key) for grouping_key in invoice_grouping_keys]): + # origins = set() + # payment_refs = set() + # refs = set() + # ref_invoice_vals = None + # for invoice_vals in invoices: + # if not ref_invoice_vals: + # ref_invoice_vals = invoice_vals + # else: + # ref_invoice_vals['invoice_line_ids'] += invoice_vals['invoice_line_ids'] + # origins.add(invoice_vals['invoice_origin']) + # payment_refs.add(invoice_vals['payment_reference']) + # refs.add(invoice_vals['ref']) + # ref_invoice_vals.update({ + # 'ref': ', '.join(refs)[:2000], + # 'invoice_origin': ', '.join(origins), + # 'payment_reference': len(payment_refs) == 1 and payment_refs.pop() or False, + # }) + # new_invoice_vals_list.append(ref_invoice_vals) + # invoice_vals_list = new_invoice_vals_list + # + # # 3) Create invoices. + # + # # As part of the invoice creation, we make sure the sequence of multiple SO do not interfere + # # in a single invoice. Example: + # # SO 1: + # # - Section A (sequence: 10) + # # - Product A (sequence: 11) + # # SO 2: + # # - Section B (sequence: 10) + # # - Product B (sequence: 11) + # # + # # If SO 1 & 2 are grouped in the same invoice, the result will be: + # # - Section A (sequence: 10) + # # - Section B (sequence: 10) + # # - Product A (sequence: 11) + # # - Product B (sequence: 11) + # # + # # Resequencing should be safe, however we resequence only if there are less invoices than + # # orders, meaning a grouping might have been done. This could also mean that only a part + # # of the selected SO are invoiceable, but resequencing in this case shouldn't be an issue. + # if len(invoice_vals_list) < len(self): + # SaleOrderLine = self.env['sale.order.line'] + # for invoice in invoice_vals_list: + # sequence = 1 + # for line in invoice['invoice_line_ids']: + # line[2]['sequence'] = SaleOrderLine._get_invoice_line_sequence(new=sequence, old=line[2]['sequence']) + # sequence += 1 + # + # # Manage the creation of invoices in sudo because a salesperson must be able to generate an invoice from a + # # sale order without "billing" access rights. However, he should not be able to create an invoice from scratch. + # moves = self.env['account.move'].sudo().with_context(default_move_type='out_invoice').create(invoice_vals_list) + # + # # 4) Some moves might actually be refunds: convert them if the total amount is negative + # # We do this after the moves have been created since we need taxes, etc. to know if the total + # # is actually negative or not + # if final: + # moves.sudo().filtered(lambda m: m.amount_total < 0).action_switch_invoice_into_refund_credit_note() + # for move in moves: + # move.message_post_with_view('mail.message_origin_link', + # values={'self': move, 'origin': move.line_ids.mapped('sale_line_ids.order_id')}, + # subtype_id=self.env.ref('mail.mt_note').id + # ) + # return moves
\ No newline at end of file diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index a837a6bc..c7f4368a 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -43,7 +43,7 @@ class SaleMonitoring(models.Model): WHEN SUM(qty_to_delivered) < SUM(qty_so) and SUM(qty_to_delivered) > 0 THEN 'KIRIM SISANYA' ELSE 'Belum Invoiced' END AS status, - get_po_number(smd.sale_order_id) as po_number + 0 as po_number FROM sale_monitoring_detail smd GROUP BY smd.date_order, smd.sale_order_id, smd.partner_id, smd.user_id ) diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index 843c7348..07b62d33 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -44,7 +44,7 @@ class SaleMonitoringDetail(models.Model): p.id AS product_id, sol.product_uom_qty AS qty_so, sol.qty_delivered AS qty_so_delivered, - get_qty_to_delivered(sol.id) as qty_to_delivered, + 0 as qty_to_delivered, sol.qty_invoiced AS qty_so_invoiced, so.date_order AS date_order, get_qty_po(so.id, sol.product_id) AS qty_po, diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index e07f724e..b32d257d 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -10,6 +10,8 @@ class XManufactures(models.Model): x_description = fields.Html(string="Description") x_logo_manufacture = fields.Binary(string="Logo Manufacture") x_logo_manufacture_128 = fields.Image("Image 128", related="x_logo_manufacture", max_width=128, max_height=128, store=True) + image_promotion_1 = fields.Binary(string="Promotion Image 1") + image_promotion_2 = fields.Binary(string="Promotion Image 2") x_manufacture_level = fields.Selection([ ('prioritas', 'Prioritas'), ('gold', 'Gold'), diff --git a/indoteknik_custom/report/report_deliveryslip2.xml b/indoteknik_custom/report/report_deliveryslip2.xml new file mode 100644 index 00000000..735cee52 --- /dev/null +++ b/indoteknik_custom/report/report_deliveryslip2.xml @@ -0,0 +1,214 @@ +<odoo> + <data> + <record id="paperformat_euro_lowmargin" model="report.paperformat"> + <field name="name">A5 Delivery Slip</field> + <field name="default" eval="True"/> + <field name="format">A5</field> + <field name="page_height">0</field> + <field name="page_width">0</field> + <field name="orientation">Landscape</field> + <field name="margin_top">32.00</field> + <field name="margin_bottom">8.00</field> + <field name="margin_left">5.00</field> + <field name="margin_right">5.00</field> + <field name="header_line" eval="False"/> + <field name="header_spacing">30</field> + <field name="dpi">90</field> + </record> + <record id="stock.action_report_delivery" model="ir.actions.report"> + <field name="paperformat_id" ref="paperformat_euro_lowmargin"/> + </record> + </data> + + <template id="report_delivery_document3" inherit_id="stock.report_delivery_document"> + <xpath expr="//t[@t-call='web.external_layout']" position="replace"> + <t t-call="web.external_layout"> + <t t-set="o" t-value="o.with_context(lang=o.partner_id.lang)" /> + <!-- <t t-set="partner" t-value="o.partner_id or (o.move_lines and o.move_lines[0].partner_id) or False"/>--> + <!-- <t t-if="partner" name="partner_header">--> + <!-- <t t-set="address">--> + <!-- <span t-field="o.name"/>--> + <!-- <div t-esc="partner"--> + <!-- t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True}'/>--> + <!-- </t>--> + <!-- </t>--> + + <style> + td { + vertical-align: text-top; + } + .header { + position: fixed; + width: 100%; + top: 8px; + } + </style> + <div class="header"> + <div style="margin-bottom: 16px;"> + <span>PT. Indoteknik Dotcom Gemilang</span> + <img style="float: right;" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', o.name, 300, 50)" alt="Barcode"/> + </div> + <table> + <tr> + <td width="50%" style="padding: 0 24px 0 0; "> + <p class="mb-1">Kepada:</p> + <p t-field="o.partner_id.name"/> + <p t-field="o.partner_id.street"/> + <p t-field="o.partner_id.mobile"/> + </td> + <td width="50%" style="padding: 0 0 0 24px;"> + <p>No. Invoice: <b><span t-field="o.origin"/></b></p> + <p>No. DO: <b><span t-field="o.name"/></b></p> + </td> + </tr> + </table> + </div> + + <div class="page"> + <table class="table table-sm" t-if="o.state!='done'" name="stock_move_table"> + <thead> + <tr> + <th name="th_sm_product"><strong>Product</strong></th> + <th name="th_sm_quantity"><strong>Quantity</strong></th> + </tr> + </thead> + <tbody> + <t t-set="lines" t-value="o.move_lines.filtered(lambda x: x.product_uom_qty)"/> + <tr t-foreach="lines" t-as="move"> + <td> + <span t-field="move.product_id"/> + <p t-if="move.description_picking != move.product_id.name"> + <span t-field="move.description_picking"/> + </p> + </td> + <td style="text-align: right;"> + <span t-field="move.product_uom_qty"/> + <span t-field="move.product_uom"/> + </td> + </tr> + </tbody> + </table> + <table class="table table-sm mt48" t-if="o.move_line_ids and o.state=='done'" name="stock_move_line_table"> + <t t-set="has_serial_number" t-value="False"/> + <t t-set="has_serial_number" t-value="o.move_line_ids.mapped('lot_id')" groups="stock.group_lot_on_delivery_slip"/> + <thead> + <tr> + <th name="th_sml_product"><strong>Product</strong></th> + <t name="lot_serial" t-if="has_serial_number"> + <th> + Lot/Serial Number + </th> + </t> + <th name="th_sml_quantity" class="text-center"><strong>Quantity</strong></th> + </tr> + </thead> + <tbody> + <!-- This part gets complicated with different use cases (additional use cases in extensions of this report): + 1. If serial numbers are used and set to print on delivery slip => print lines as is, otherwise group them by overlapping + product + description + uom combinations + 2. If any packages are assigned => split products up by package (or non-package) and then apply use case 1 --> + <!-- If has destination packages => create sections of corresponding products --> + <t t-if="o.has_packages" name="has_packages"> + <t t-set="packages" t-value="o.move_line_ids.mapped('result_package_id')"/> + <t t-foreach="packages" t-as="package"> + <t t-call="stock.stock_report_delivery_package_section_line"/> + <t t-set="package_move_lines" t-value="o.move_line_ids.filtered(lambda l: l.result_package_id == package)"/> + <!-- If printing lots/serial numbers => keep products in original lines --> + <t t-if="has_serial_number"> + <tr t-foreach="package_move_lines" t-as="move_line"> + <t t-call="stock.stock_report_delivery_has_serial_move_line"/> + </tr> + </t> + <!-- If not printing lots/serial numbers => merge lines with same product+description+uom --> + <t t-else=""> + <t t-set="aggregated_lines" t-value="package_move_lines._get_aggregated_product_quantities()"/> + <t t-call="stock.stock_report_delivery_aggregated_move_lines"/> + </t> + </t> + <!-- Make sure we do another section for package-less products if they exist --> + <t t-set="move_lines" t-value="o.move_line_ids.filtered(lambda l: not l.result_package_id)"/> + <t t-if="move_lines" name="no_package_move_lines"> + <t t-call="stock.stock_report_delivery_no_package_section_line" name="no_package_section"/> + <t t-if="has_serial_number"> + <tr t-foreach="move_lines" t-as="move_line"> + <t t-call="stock.stock_report_delivery_has_serial_move_line"/> + </tr> + </t> + <t t-else=""> + <t t-set="aggregated_lines" t-value="move_lines._get_aggregated_product_quantities()"/> + <t t-if="aggregated_lines"> + <t t-call="stock.stock_report_delivery_aggregated_move_lines"/> + </t> + </t> + </t> + </t> + <!-- No destination packages --> + <t t-else=""> + <!-- If printing lots/serial numbers => keep products in original lines --> + <t t-if="has_serial_number"> + <tr t-foreach="o.move_line_ids" t-as="move_line"> + <t t-call="stock.stock_report_delivery_has_serial_move_line"/> + </tr> + </t> + <!-- If not printing lots/serial numbers => merge lines with same product --> + <t t-else="" name="aggregated_move_lines"> + <t t-set="aggregated_lines" t-value="o.move_line_ids._get_aggregated_product_quantities()"/> + <t t-call="stock.stock_report_delivery_aggregated_move_lines"/> + </t> + </t> + </tbody> + </table> + <t t-set="backorders" t-value="o.backorder_ids.filtered(lambda x: x.state not in ('done', 'cancel'))"/> + <t t-if="o.backorder_ids and backorders"> + <p> + <span>All items couldn't be shipped, the following items will be shipped as soon as they become available.</span> + </p> + <table class="table table-sm" name="stock_backorder_table"> + <thead> + <tr> + <th name="th_sb_product"><strong>Product</strong></th> + <th name="th_sb_quantity" class="text-center"><strong>Quantity</strong></th> + </tr> + </thead> + <tbody> + <t t-foreach="backorders" t-as="backorder"> + <t t-set="bo_lines" t-value="backorder.move_lines.filtered(lambda x: x.product_uom_qty)"/> + <tr t-foreach="bo_lines" t-as="bo_line"> + <td> + <span t-field="bo_line.product_id"/> + <p t-if="bo_line.description_picking != bo_line.product_id.name"> + <span t-field="bo_line.description_picking"/> + </p> + </td> + <td class="text-center"> + <span t-field="bo_line.product_uom_qty"/> + <span t-field="bo_line.product_uom"/> + </td> + </tr> + </t> + </tbody> + </table> + </t> + + <div t-if="o.signature" class="mt32 ml64 mr4" name="signature"> + <div class="offset-8"> + <strong>Signature</strong> + </div> + <div class="offset-8"> + <img t-att-src="image_data_uri(o.signature)" style="max-height: 4cm; max-width: 8cm;"/> + </div> + <div class="offset-8 text-center"> + <p t-field="o.partner_id.name"/> + </div> + </div> + </div> + </t> + </xpath> +<!-- <xpath expr="//div/h2" position="replace">--> +<!-- <div style="margin: 16px 0;">--> +<!-- <span class="h2" t-field="o.name"/>--> +<!-- <img style="float: right;" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', o.name, 300, 50)" alt="Barcode"/>--> +<!-- </div>--> +<!-- </xpath>--> + </template> +</odoo> diff --git a/indoteknik_custom/static/src/js/delivery_order.js b/indoteknik_custom/static/src/js/delivery_order.js new file mode 100644 index 00000000..565610ad --- /dev/null +++ b/indoteknik_custom/static/src/js/delivery_order.js @@ -0,0 +1,44 @@ +odoo.define('indoteknik_custom.FieldChar', function (require) { + "use strict"; + + console.log('12345'); + var FieldChar = require('web.basic_fields').FieldChar; + var registry = require('web.field_registry'); + + var FieldCharCustom = FieldChar.extend({ + _onKeyup: function (ev) { + console.log('keyuppp'); + if (ev.which === $.ui.keyCode.ENTER) { + console.log('abc'); + } + this._super.apply(this, arguments); + }, + }); + + registry.add('name', FieldCharCustom); + + return FieldCharCustom; + +// var core = require('web.core'); +// var _t = core._t; +// var FormView = require('web.FormView'); + +// FormView.include({ +// init: function (parent, model, renderer, params) { +// var self = this; +// self._super.apply(self.arguments); +// }, +// onchange_name: function () { +// this._super(); +// console.log('bbbb'); +// if (this.model === 'delivery.order') { +// this.$('#name').on('keyup', function () { +// console.log('aaa') +// }); +// } +// } +// }); +// +// core.action_registry.add('indoteknik_custom.FieldChar', FormView); +// return FormView; +});
\ No newline at end of file diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index afecea9b..e7e1b85d 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -43,6 +43,8 @@ </group> <group> <field name="x_logo_manufacture" widget="image"/> + <field name="image_promotion_1" widget="image" width="80" /> + <field name="image_promotion_2" widget="image" width="80" /> </group> </group> <notebook> |
