diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-12-26 17:39:05 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-12-26 17:39:05 +0700 |
| commit | f9f4b55c57461fa7cb0a4d3fb6fc9e85f53fe9c2 (patch) | |
| tree | 9945b3df169eeddd790cd0f40df673ece17bf2d1 | |
| parent | db2f280683b29ac5d32158f3fab0f3df671935e9 (diff) | |
window sales target
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 16 | ||||
| -rw-r--r-- | indoteknik_custom/models/sales_target.py | 54 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/sales_target.xml | 51 |
6 files changed, 125 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 633d407b..d8bf8d4c 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -48,6 +48,7 @@ 'views/dunning_run.xml', 'views/website_brand_homepage.xml', 'views/website_categories_homepage.xml', + 'views/sales_target.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 dc85ce96..c8cd85b5 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -35,3 +35,4 @@ from . import website_user_wishlist from . import website_brand_homepage from . import mail_mail from . import website_categories_homepage +from . import sales_target diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 9ddaf91c..dbbd4ad4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -36,6 +36,14 @@ class ProductTemplate(models.Model): search_rank = fields.Integer(string='Search Rank', default=0) search_rank_weekly = fields.Integer(string='Search Rank Weekly', default=0) supplier_url = fields.Char(string='Vendor URL') + # custom field for support Trusco products + maker_code = fields.Char(string='Maker Code') + maker_name = fields.Char(string='Maker Name') + origin = fields.Char(string='Origin') + features = fields.Char(string='Features') + usage = fields.Char(string='Usage') + specification = fields.Char(string='Specification') + material = fields.Char(string='Material') # def write(self, vals): # if 'solr_flag' not in vals and self.solr_flag == 1: @@ -182,6 +190,14 @@ class ProductProduct(models.Model): 'Qty Stock Vendor', compute='_compute_stock_vendor', help="Stock Vendor") solr_flag = fields.Integer(string='Solr Flag', default=0) + # custom field for support Trusco products + maker_code = fields.Char(string='Maker Code') + maker_name = fields.Char(string='Maker Name') + origin = fields.Char(string='Origin') + features = fields.Char(string='Features') + usage = fields.Char(string='Usage') + specification = fields.Char(string='Specification') + material = fields.Char(string='Material') # def write(self, vals): # if 'solr_flag' not in vals: diff --git a/indoteknik_custom/models/sales_target.py b/indoteknik_custom/models/sales_target.py new file mode 100644 index 00000000..5d2d6310 --- /dev/null +++ b/indoteknik_custom/models/sales_target.py @@ -0,0 +1,54 @@ +from odoo import fields, models, api +from datetime import datetime, timedelta +import logging + +_logger = logging.getLogger(__name__) + + +class SalesTarget(models.Model): + _name = 'sales.target' + + partner_id = fields.Many2one('res.partner', string='Customer') + period = fields.Integer(string='Periode') + omset_last_year = fields.Float(string='Omset Tahun Lalu') + ongoing_omset_odoo = fields.Float(string='Omset Berjalan Odoo', compute='_compute_ongoing_omset') + ongoing_omset_accurate = fields.Float(string='Omset Berjalan Accurate') + ongoing_omset_adempiere = fields.Float(string='Omset Berjalan ADempiere') + ongoing_omset_total = fields.Float(string='Total Omset', compute='_compute_total_omset') + + def _compute_total_omset(self): + for target in self: + target.ongoing_omset_total = target.ongoing_omset_odoo + target.ongoing_omset_accurate + target.ongoing_omset_adempiere + + def _compute_ongoing_omset(self): + for target in self: + target.ongoing_omset_odoo = 0 + if not target.ids: + return True + + partners = [] + if target.partner_id.parent_id: + parent_id = target.partner_id.parent_id + else: + parent_id = target.partner_id + partners += parent_id.child_ids + partners.append(parent_id) + + datefrom = datetime(target.period, 1, 1, 00, 00) + # datefrom = datefrom.strftime('%Y-%m-%d %H:%M:%S') + dateto = datetime(target.period, 12, 31, 23, 59) + # dateto = dateto.strftime('%Y-%m-%d %H:%M:%S') + + total_omset = 0 + for partner in partners: + domain = [ + ('partner_id', '=', partner.id), + ('state', 'not in', ['draft', 'cancel']), + ('move_type', 'in', ('out_invoice', 'out_refund')), + ('invoice_date', '>=', datefrom), + ('invoice_date', '<=', dateto) + ] + invoices = target.env['account.move'].search(domain) + for invoice in invoices: + total_omset += invoice.amount_untaxed + target.ongoing_omset_odoo = total_omset diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 295da4ee..874ff7ce 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -17,4 +17,5 @@ access_dunning_run_line,access.dunning.run.line,model_dunning_run_line,,1,1,1,1 access_website_user_cart,access.website.user.cart,model_website_user_cart,,1,1,1,1 access_website_user_wishlist,access.website.user.wishlist,model_website_user_wishlist,,1,1,1,1 access_website_brand_homepage,access.website.brand.homepage,model_website_brand_homepage,,1,1,1,1 -access_website_categories_homepage,access.website.categories.homepage,model_website_categories_homepage,,1,1,1,1
\ No newline at end of file +access_website_categories_homepage,access.website.categories.homepage,model_website_categories_homepage,,1,1,1,1 +access_sales_target,access.sales.target,model_sales_target,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/sales_target.xml b/indoteknik_custom/views/sales_target.xml new file mode 100644 index 00000000..39462ad7 --- /dev/null +++ b/indoteknik_custom/views/sales_target.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="sales_target_action" model="ir.actions.act_window"> + <field name="name">Sales Target</field> + <field name="res_model">sales.target</field> + <field name="view_mode">tree,form</field> + </record> + + <record id="sales_target_tree" model="ir.ui.view"> + <field name="name">Sales Target</field> + <field name="model">sales.target</field> + <field name="arch" type="xml"> + <tree> + <field name="partner_id"/> + <field name="period"/> + <field name="omset_last_year"/> + <field name="ongoing_omset_total"/> + </tree> + </field> + </record> + + <record id="sales_target_form" model="ir.ui.view"> + <field name="name">Sales Target</field> + <field name="model">sales.target</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="partner_id"/> + <field name="period"/> + <field name="omset_last_year"/> + <field name="ongoing_omset_odoo"/> + <field name="ongoing_omset_accurate"/> + <field name="ongoing_omset_adempiere"/> + </group> + </group> + </sheet> + </form> + </field> + </record> + <menuitem + id="sale_target_menu" + action="sales_target_action" + parent="sale.menu_sales_config" + sequence="2" + name="Sales Target" + /> + </data> +</odoo>
\ No newline at end of file |
