diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-08-23 02:30:51 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-08-23 02:30:51 +0000 |
| commit | 6aa301a106b822234af2812c9633f5b907ad2c53 (patch) | |
| tree | ff62225d7d409a2dc7c62f12a3be8944d4247649 | |
| parent | 77abcebaa3c7532107c4dd3ba3854b25a3dc03e3 (diff) | |
| parent | c369d67e08b50350705011e01b3f5ec78dcb7d11 (diff) | |
Merged in development (pull request #1)
Development
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_asset.py | 12 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 7 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 60 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 108 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_asset_views.xml | 18 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 41 |
9 files changed, 193 insertions, 59 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 58b8a3df..919a61a2 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -30,6 +30,8 @@ 'views/x_product_tags.xml', 'views/stock_vendor.xml', 'views/crm_lead.xml', + 'views/sale_order.xml', + 'views/account_asset_views.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 02e223fd..25341923 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -14,5 +14,8 @@ from . import user_activity_log from . import purchase_order from . import purchase_pricelist from . import purchase_order_line +from . import sale_order from . import sale_monitoring_detail from . import sale_monitoring +from . import account_move +from . import account_asset diff --git a/indoteknik_custom/models/account_asset.py b/indoteknik_custom/models/account_asset.py new file mode 100644 index 00000000..bd5f9adb --- /dev/null +++ b/indoteknik_custom/models/account_asset.py @@ -0,0 +1,12 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError + + +class AccountAsset(models.Model): + _inherit = 'account.asset.asset' + + def action_close_asset(self): + for asset in self: + if asset.value > 0: + raise UserError("Asset masih mempunyai Value") + asset.state = 'close' diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py new file mode 100644 index 00000000..224e22ec --- /dev/null +++ b/indoteknik_custom/models/account_move.py @@ -0,0 +1,7 @@ +from odoo import models, api, fields + + +class AccountMove(models.Model): + _inherit = 'account.move' + date_send_fp = fields.Datetime(string="Tanggal Kirim Faktur Pajak") + last_log_fp = fields.Char(string="Log Terakhir Faktur Pajak") diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 2c589d36..cb048182 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -8,7 +8,6 @@ class PurchaseOrder(models.Model): procurement_status = fields.Char(string='Procurement Status', compute='get_procurement_status',readonly=True) def get_procurement_status(self): - for purchase_order in self: product_uom_qty = sum_qty_received = 0 diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 74b46e4c..b4be9ffc 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -6,66 +6,9 @@ class PurchaseOrderLine(models.Model): _inherit = 'purchase.order.line' # Override method from addons/purchase/models/purchase.py - @api.onchange('product_id') - def onchange_product_id(self): - if not self.product_id: - return - - # Reset date, price and quantity since _onchange_quantity will provide default values - self.price_unit = self.product_qty = 0.0 - - self._product_id_change() - - self._suggest_quantity() - self._onchange_quantity() - - # Override method from addons/purchase/models/purchase.py @api.onchange('product_qty', 'product_uom') def _onchange_quantity(self): - if not self.product_id: - return - params = {'order_id': self.order_id} - seller = self.product_id._select_seller( - partner_id=self.partner_id, - quantity=self.product_qty, - date=self.order_id.date_order and self.order_id.date_order.date(), - uom_id=self.product_uom, - params=params) - - if seller or not self.date_planned: - self.date_planned = self._get_date_planned(seller).strftime(DEFAULT_SERVER_DATETIME_FORMAT) - - # If not seller, use the standard price. It needs a proper currency conversion. - if not seller: - po_line_uom = self.product_uom or self.product_id.uom_po_id - price_unit = self.env['account.tax']._fix_tax_included_price_company( - self.product_id.uom_id._compute_price(self.product_id.standard_price, po_line_uom), - self.product_id.supplier_taxes_id, - self.taxes_id, - self.company_id, - ) - if price_unit and self.order_id.currency_id and self.order_id.company_id.currency_id != self.order_id.currency_id: - price_unit = self.order_id.company_id.currency_id._convert( - price_unit, - self.order_id.currency_id, - self.order_id.company_id, - self.date_order or fields.Date.today(), - ) - - self.price_unit = price_unit - #return - - price_unit = self.env['account.tax']._fix_tax_included_price_company(seller.price, - self.product_id.supplier_taxes_id, - self.taxes_id, - self.company_id) if seller else 0.0 - if price_unit and seller and self.order_id.currency_id and seller.currency_id != self.order_id.currency_id: - price_unit = seller.currency_id._convert( - price_unit, self.order_id.currency_id, self.order_id.company_id, self.date_order or fields.Date.today()) - - if seller and self.product_uom and seller.product_uom != self.product_uom: - price_unit = seller.product_uom._compute_price(price_unit, self.product_uom) - + res = super(PurchaseOrderLine, self)._onchange_quantity() # Custom script purchase_pricelist = self.env['purchase.pricelist'].search([ ('product_id', '=', self.product_id.id), @@ -81,3 +24,4 @@ class PurchaseOrderLine(models.Model): price_unit = product_supplierinfo.price self.price_unit = price_unit + return res diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py new file mode 100755 index 00000000..50e6baa3 --- /dev/null +++ b/indoteknik_custom/models/sale_order.py @@ -0,0 +1,108 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError + +import warnings + + +class SaleOrder(models.Model): + _inherit = "sale.order" + total_margin = fields.Float( + 'Total Margin', compute='compute_total_margin', + help="Total Margin in Sales Order Header") + total_percent_margin = fields.Float( + 'Total Percent Margin', compute='compute_total_margin', + help="Total % Margin in Sales Order Header") + approval_status = fields.Selection([ + ('pengajuan1', 'Approval Adela'), + ('pengajuan2', 'Approval Tyas'), + ('approved', 'Approved'), + ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) + + # def sale_order_approve(self): + # for order in self: + # if order.state == 'cancel' or order.state == 'done' or order.state == 'sale': + # raise UserError("Status harus draft atau sent") + # approval1 = approval2 = 0 + # for line in order.order_line: + # if not line.product_id: + # continue + # if (line.item_percent_margin <= 15 or line.item_percent_margin == 100) and ( + # self.env.user.id != 6 and self.env.user.id != 7): + # approval2 += 1 + # # order.approval_status = "pengajuan2" + # # break + # elif line.item_percent_margin <= 40 and (self.env.user.id != 8 and self.env.user.id != 6 and self.env.user.id != 7): + # approval1 += 1 + # # order.approval_status = 'pengajuan1' + # # break + # if approval2 > 0: + # order.approval_status = 'pengajuan2' + # elif approval1 > 0: + # order.approval_status = 'pengajuan1' + # else: + # raise UserError("Bisa langsung Confirm") + + # def action_cancel(self): + # self.approval_status = False + # return super(SaleOrder, self).action_cancel() + + def compute_total_margin(self): + for order in self: + total_margin = total_percent_margin = 0 + for line in order.order_line: + if not line.product_id: + order.total_margin = 0 + order.total_percent_margin = 0 + continue + total_margin += line.item_margin + order.total_margin = total_margin + if order.amount_untaxed > 0: + total_percent_margin = round((total_margin / order.amount_untaxed), 4) * 100 + order.total_percent_margin = total_percent_margin + + # def action_confirm(self): + # res = super(SaleOrder, self).action_confirm() + # for order in self: + # approval1 = approval2 = 0 + # for line in order.order_line: + # if not line.product_id: + # continue + # if (line.item_percent_margin <= 15 or line.item_percent_margin == 100) and ( + # self.env.user.id != 6 and self.env.user.id != 7): + # approval2 += 1 + # elif line.item_percent_margin <= 40 and ( + # self.env.user.id != 8 and self.env.user.id != 6 and self.env.user.id != 7): + # approval1 += 1 + # if approval2 > 0: + # raise UserError("Need Tyas / Akbar Approval, atau Approval manual dan lampirkan di Log Internal") + # elif approval1 > 0: + # raise UserError("Need Adela Approval") + # order.approval_status = 'approved' + # return res + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + item_margin = fields.Float( + 'Total Margin', compute='compute_item_margin', + help="Total Margin in Sales Order Header") + item_percent_margin = fields.Float( + 'Total Percent Margin', compute='compute_item_margin', + help="Total % Margin in Sales Order Header") + + def compute_item_margin(self): + for line in self: + if not line.product_id: + line.item_margin = 0 + line.item_percent_margin = 0 + continue + subtotal_untaxed = line.price_subtotal + purchase_pricelist = self.env['purchase.pricelist'].search( + [('product_id', '=', line.product_id.id)], limit=1, order='product_price') + purchase_pricelist_untaxed = 0 + if purchase_pricelist.product_price > 0: + purchase_pricelist_untaxed = purchase_pricelist.product_price / 1.11 + margin_per_item = subtotal_untaxed - (purchase_pricelist_untaxed * line.product_uom_qty) + line.item_margin = margin_per_item + if subtotal_untaxed > 0: + line.item_percent_margin = round((margin_per_item / subtotal_untaxed), 4) * 100 diff --git a/indoteknik_custom/views/account_asset_views.xml b/indoteknik_custom/views/account_asset_views.xml new file mode 100644 index 00000000..90c53623 --- /dev/null +++ b/indoteknik_custom/views/account_asset_views.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="account_asset_form_view_inherit" model="ir.ui.view"> + <field name="name">Account Asset</field> + <field name="model">account.asset.asset</field> + <field name="inherit_id" ref="base_accounting_kit.view_account_asset_asset_form"/> + <field name="arch" type="xml"> + <button name="set_to_draft" position="after"> + <button name="action_close_asset" + string="Close Asset" + type="object" + /> + </button> + </field> + </record> + </data> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml new file mode 100755 index 00000000..82058837 --- /dev/null +++ b/indoteknik_custom/views/sale_order.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="sale_order_form_view_inherit" model="ir.ui.view"> + <field name="name">Sale Order</field> + <field name="model">sale.order</field> + <field name="inherit_id" ref="sale.view_order_form"/> + <field name="arch" type="xml"> + <button id="action_confirm" position="after"> +<!-- <button name="sale_order_approve"--> +<!-- string="Ask Approval"--> +<!-- type="object"--> +<!-- />--> + </button> + <field name="payment_term_id" position="after"> + <field name="approval_status" /> + </field> + <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_total']" position="after"> + <field name="item_margin" groups="sales_team.group_sale_manager"/> + <field name="item_percent_margin" groups="sales_team.group_sale_manager"/> + </xpath> + <field name="amount_total" position="after"> + <field name="total_margin" groups="sales_team.group_sale_manager"/> + <field name="total_percent_margin" groups="sales_team.group_sale_manager"/> + </field> + </field> + </record> + </data> + <data> + <record id="sale_order_tree_view_inherit" model="ir.ui.view"> + <field name="name">Sale Order</field> + <field name="model">sale.order</field> + <field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding"/> + <field name="arch" type="xml"> + <field name="state" position="after"> + <field name="approval_status" /> + </field> + </field> + </record> + </data> +</odoo>
\ No newline at end of file |
