diff --git a/.gitignore b/.gitignore index f522c0579..583082b9d 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,9 @@ dmypy.json # github action .github/workflows/*yaml + +# config +.config/ + +# vscode +.vscode/ \ No newline at end of file diff --git a/odex25_donation/abs_prodcut_invoices/models/product_template.py b/odex25_donation/abs_prodcut_invoices/models/product_template.py deleted file mode 100644 index 427065d37..000000000 --- a/odex25_donation/abs_prodcut_invoices/models/product_template.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- -################################################################################# -# -# Odoo, Open Source Management Solution -# Copyright (C) 2020-today Ascetic Business Solution -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -################################################################################# - -from odoo import api, fields, models, _ - -#Class is Extended for new features, which are displaying two tables for total customer invoice and total vendor bills on particular product form, also display its button with total amount of that product. -class ProductTemplateInvoiceAmount(models.Model): - _inherit = "product.template" - - cust_invoice_line_ids = fields.One2many('account.move.line','template_id', string='Customer Invoice',compute='_compute_get_customer_invoices_in_product',help='get particular products invoice id from all customers invoices') - - vendor_bill_line_ids = fields.One2many('account.move.line','template_id', string='Vendor Bill Line',compute='_compute_get_vendor_bills_in_product',help='get particular products invoice id from all vendors bills') - - #compute customers invoices on product, which is related to that product. - def _compute_get_customer_invoices_in_product(self): - for record in self: - if record.id: - cust_invoice=self.env['account.move.line'].search([('product_id.product_tmpl_id','=',self.id),('move_id.move_type','=','out_invoice')]) - record.cust_invoice_line_ids = cust_invoice - else: - record.cust_invoice_line_ids = False - - #compute vendor bills invoices on product, which is related to that product. - def _compute_get_vendor_bills_in_product(self): - for record in self: - if record.id: - vendor_bill=self.env['account.move.line'].search([('product_id.product_tmpl_id','=',self.id),('move_id.move_type','=','in_invoice')]) - record.vendor_bill_line_ids = vendor_bill - else: - record.vendor_bill_line_ids = False - -#Class is Extended for new features,take template_id and invoice_state from account.invoice.line to product.template. -class AccountMoveIn(models.Model): - _inherit = "account.move.line" - - template_id = fields.Many2one('product.template',string="template ids",compute='get_template_id',help='This field is in relation with customer invoice and vendor bills') - - invoice_state = fields.Selection([('draft','Draft'),('posted', 'Posted'),('cancel', 'Cancelled'),], string='Status',compute='get_template_id', index=True, readonly=True, default='draft',track_visibility='onchange', copy=False,help=" * The 'Draft' status is used when a user is encoding a new and unconfirmed Invoice.\n"" * The 'Pro-forma' status is used when the invoice does not have an invoice number.\n"" * The 'Open' status is used when user creates invoice, an invoice number is generated. It stays in the open status till the user pays the invoice.\n"" * The 'Paid' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled.\n"" * The 'Cancelled' status is used when user cancel invoice.") - - ### Add one field for invoice number and vendor bill number - number = fields.Char(compute='get_template_id') - - #Create template_id(product_id.product_tmpl_id) from product_id and create invoice_state from invoice_id. - def get_template_id(self): - for record in self: - if record.product_id: - record.template_id = record.product_id.product_tmpl_id - else: - record.template_id = False - for record in self: - if record.move_id: - record.invoice_state = record.move_id.state - else: - record.invoice_state = False - for record in self: - if record.move_id: - record.number = record.move_id.name - else: - record.number = False diff --git a/odex25_donation/abs_prodcut_invoices/views/product_template_view.xml b/odex25_donation/abs_prodcut_invoices/views/product_template_view.xml deleted file mode 100644 index 22ed3aef7..000000000 --- a/odex25_donation/abs_prodcut_invoices/views/product_template_view.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - product.template.product.form - product.template - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/odex25_donation/abs_prodcut_invoices/__init__.py b/odex25_donation/abs_product_invoices/__init__.py similarity index 100% rename from odex25_donation/abs_prodcut_invoices/__init__.py rename to odex25_donation/abs_product_invoices/__init__.py diff --git a/odex25_donation/abs_prodcut_invoices/__manifest__.py b/odex25_donation/abs_product_invoices/__manifest__.py similarity index 96% rename from odex25_donation/abs_prodcut_invoices/__manifest__.py rename to odex25_donation/abs_product_invoices/__manifest__.py index e9d3c4d5a..eff8009f6 100644 --- a/odex25_donation/abs_prodcut_invoices/__manifest__.py +++ b/odex25_donation/abs_product_invoices/__manifest__.py @@ -31,7 +31,5 @@ 'depends': ['base','sale_management'], 'data': ['views/product_template_view.xml'], 'images': ['static/description/banner.png'], - 'installable': True, - 'application': True, 'auto_install': False, } diff --git a/odex25_donation/abs_prodcut_invoices/models/__init__.py b/odex25_donation/abs_product_invoices/models/__init__.py similarity index 100% rename from odex25_donation/abs_prodcut_invoices/models/__init__.py rename to odex25_donation/abs_product_invoices/models/__init__.py diff --git a/odex25_donation/abs_product_invoices/models/product_template.py b/odex25_donation/abs_product_invoices/models/product_template.py new file mode 100644 index 000000000..a87eecd5e --- /dev/null +++ b/odex25_donation/abs_product_invoices/models/product_template.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +################################################################################# +# +# Odoo, Open Source Management Solution +# Copyright (C) 2020-today Ascetic Business Solution +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################# + +from odoo import fields, models + +class ProductTemplateInvoiceAmount(models.Model): + _inherit = "product.template" + + sale_move_line_ids = fields.One2many('account.move.line','product_template_id', readonly=True, domain=[('move_id.move_type','=','out_invoice')]) + + purchase_move_line_ids = fields.One2many('account.move.line','product_template_id', readonly=True, domain=[('move_id.move_type','=','in_invoice')]) + +class AccountMoveIn(models.Model): + _inherit = "account.move.line" + + product_template_id = fields.Many2one('product.template', related='product_id.product_tmpl_id', store=True) + diff --git a/odex25_donation/abs_prodcut_invoices/static/description/banner.png b/odex25_donation/abs_product_invoices/static/description/banner.png similarity index 100% rename from odex25_donation/abs_prodcut_invoices/static/description/banner.png rename to odex25_donation/abs_product_invoices/static/description/banner.png diff --git a/odex25_donation/abs_prodcut_invoices/static/description/company-logo.png b/odex25_donation/abs_product_invoices/static/description/company-logo.png similarity index 100% rename from odex25_donation/abs_prodcut_invoices/static/description/company-logo.png rename to odex25_donation/abs_product_invoices/static/description/company-logo.png diff --git a/odex25_donation/abs_prodcut_invoices/static/description/icon.png b/odex25_donation/abs_product_invoices/static/description/icon.png similarity index 100% rename from odex25_donation/abs_prodcut_invoices/static/description/icon.png rename to odex25_donation/abs_product_invoices/static/description/icon.png diff --git a/odex25_donation/abs_prodcut_invoices/static/description/index.html b/odex25_donation/abs_product_invoices/static/description/index.html similarity index 100% rename from odex25_donation/abs_prodcut_invoices/static/description/index.html rename to odex25_donation/abs_product_invoices/static/description/index.html diff --git a/odex25_donation/abs_product_invoices/views/product_template_view.xml b/odex25_donation/abs_product_invoices/views/product_template_view.xml new file mode 100644 index 000000000..80325f8fc --- /dev/null +++ b/odex25_donation/abs_product_invoices/views/product_template_view.xml @@ -0,0 +1,45 @@ + + + + + product.template.product.form + product.template + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/odex25_donation/affiliate_management/.gitignore b/odex25_donation/affiliate_management/.gitignore deleted file mode 100644 index cf14435c9..000000000 --- a/odex25_donation/affiliate_management/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.pyc -.idea/ -controller/__pycache__ -models/__pycache__ \ No newline at end of file diff --git a/odex25_donation/affiliate_management/LICENSE b/odex25_donation/affiliate_management/LICENSE deleted file mode 100644 index b53403939..000000000 --- a/odex25_donation/affiliate_management/LICENSE +++ /dev/null @@ -1,398 +0,0 @@ -SOFTWARE LICENCE AGREEMENT -========================== - -This AGREEMENT is made effective on the date of the purchase of the software -between Webkul Software Pvt. Ltd.,Company incorporated under the Companies -Act, 1956 (hereinafter referred to as “Licensor"), and the purchaser of the -software/ product (hereinafter referred to as "Licensee"). - - -Preamble --------- - -Licensor is a web and mobile product based organization engaged in the -business of developing and marketing software for enterprise level e-commerce -businesses. It is an ISO and NSR (NASSCOM) certified organization having a -team of more than 150 creative engineers which come from different -backgrounds. It has developed more than 700 web extensions and apps in the -past few years for open source platforms which are used and trusted globally. -Licensee now wishes to obtain license, and Licensor wishes to grant a license, -to allow use of the software so purchased in developing the e-commerce -business website/ mobile app of the Licensee, subject to the terms and -conditions set forth herein. - -THEREFORE, with the intent to be legally bound, the parties hereby agree as -follows: - - -Agreement ---------- - -1.DEFINITIONS. -As used in this Agreement, the following capitalized terms -shall have the definitions set forth below: - -"Derivative Works" are works developed by Licensee, its officers, agents, -contractors or employees, which are based upon, in whole or in part, the -Source Code and/or the Documentation and may also be based upon and/or -incorporate one or more other preexisting works of the Licensor. Derivative -Works may be any improvement, revision, modification, translation (including -compilation or recapitulation by computer), abridgment, condensation, -expansion, or any other form in which such a preexisting work may be recast, -transformed, or adapted. For purposes hereof, a Derivative Work shall also -include any compilation that incorporates such a preexisting work. - -"Documentation" is written, printed or otherwise recorded or stored (digital -or paper) material relating to the Software and/or Source Code, including -technical specifications and instructions for its use including Software/ -Source Code annotations and other descriptions of the principles of its -operation and instructions for its use. - -"Improvements" shall mean, with respect to the Software, all modifications and -changes made, developed, acquired or conceived after the date hereof and -during the entire term of this Agreement. - -"Source Code" is the computer programming source code form of the Software in -the form maintained by the Licensor, and includes all non-third-party -executables, libraries, components, and Documentation created or used in the -creation, development, maintenance, and support of the Software as well as all -updates, error corrections and revisions thereto provided by Licensor, in -whole or in part. - - -2.SOFTWARE LICENSE. - -(a)Grant of License. For the consideration set forth below, Licensor hereby -grants to Licensee, and Licensee hereby accepts the worldwide, non-exclusive, -perpetual, royalty-free rights and licenses set forth below: - -(i)The right and license to use and incorporate the software, in whole or in -part, to develop its website/ mobile app (including the integration of all or -part of the Licensor’s software into Licensee's own software) on one domain ( -Except Joomla modules , listed on store are entitled to be used on unlimited -domain as per the standard guidelines ) only, solely for the own personal or -business use of the Licensee. However, the License does not authorize the -Licensee to compile, copy or distribute the said Software or its Derivative -Works. - -(ii)The right and license does not authorize the Licensee to share any backup -or archival copies of the Software and / or the Source Code and Documentation -on any public internet space including github , stackoverflow etc . The -Licensee must ensure that the backup are not accessible to any other person -and the Licensee must prevent copying / use of source code by any unauthorized -persons. - -(iii)The right and license does not authorize the Licensee to migrate the -domain license to another domain. - -(iv)Our Joomla extensions are published under the GNU/GPL. - - -(b)Scope; Rights and Responsibilities. - -(i)Licensor shall enable the Licensee to download one complete copy of the -Software. - -(ii)The Software is intended for the sole use of the Licensee in development -of its own website/ mobile app. - -(iii)Licensee does not have the right to hand over, sell, distribute, -sub-license, rent, lease or lend any portion of the Software or Documentation, -whether modified or unmodified, to anyone. Licensee should not place the -Software on a server so that it becomes accessible via a public network such -as the Internet for distribution purposes. In case the Licensee is using any -source code management system like github, it can use the code there only when -it has paid subscription from such management system. - -(iv) In case the Licensee purchases the module and allow the third party -development agency to customize as per its need, it is at liberty to do so -subject to the condition that the Licensee as well as the Agency are not -authorized to sell the modified version of the extension. Except for the -required customization purposes, Licensee is not authorized to release the -Source Code, Derivative Work source code and/or Documentation to any third -party, which shall be considered as violation of the Agreement, inter-alia -entailing forthwith termination and legal action. - - -(c)Ownership. - -(i)Software and Source Code. All right, title, copyright, and interest in the -Software, Source Code, Software Modifications and Error corrections will be -and remain the property of Licensor. - -(ii)Derivative Works. As creation of Derivative Works by the Licensee is -prohibited, thus, all right, title, copyright, and interest in any and/or all -Derivative Works and Improvements created by, or on behalf of, Licensee will -also be deemed to the property of Licensor. Licensor shall be entitled to -protect copyright / intellectual property in all such Derivative Works and -Improvements also in any country as it may deem fit including without -limitation seeking copyright and/or patent protection. - - -3.CONSIDERATION. - -(a)Licensee shall pay to Licensor the amount as mentioned on the website from -where the order is placed, as one-time, upfront fees in consideration for the -licenses and rights granted hereunder (hereinafter referred to as the "License -Fee"). The License Fee to be paid by Licensee shall be paid upfront at the -time of placing the order, and no credit will be allowed under any -circumstances. - -(b)Once paid, the License Fees shall be non-refundable. The Licensee has fully -satisfied itself about the Software and has seen the demonstration, and only -thereafter has placed the order. Thus, the License Fees or any part thereof is -non-refundable. No claim for refund of the Licence Fees shall be entertained -under any circumstances. - - -4.REPRESENTATIONS AND WARRANTIES. - -(a)Mutual. Each of the parties represents and warrants to the other as -follows. - -(i)such party is a legal entity duly organized, validly existing and in good -standing; - -(ii)such party has the power and authority to conduct its business as -presently conducted and to enter into, execute, deliver and perform this -Agreement. - -(iii)This Agreement has been duly and validly accepted by such party and -constitutes the legal, valid and binding obligations of such party -respectively, enforceable against such party in accordance with their -respective terms; - -(iv)the acceptance, execution, delivery and performance of this Agreement does -not and will not violate such party's charter or by-laws; nor require any -consent, authorization, approval, exemption or other action by any third party -or governmental entity. - - -(b)Licensor warrants that, at the time of purchase of the Software: - -the Software will function materially as set forth in the website or published -functionality provided by Licensor to customers and potential customers -describing the Software; and - -Software add-ons, if purchased by the Licensee from the Licensor, will not -materially diminish the features or functions of or the specifications of the -Software as they existed as of the execution of this Agreement. - - -(c)Title. Licensor represents and warrants that it is the exclusive owner of -all copyright/ intellectual property in the Software (including the Source -Code) and has good and marketable title to the Software (including the Source -Code) free and clear of all liens, claims and encumbrances of any nature -whatsoever (collectively, "Liens"). Licensor's grant of license and rights to -Licensee hereunder does not, and will not infringe any third party's property, -intellectual property or personal rights. - - -5.TERM. - -(a)Subject to Licensee's payment obligations, this Agreement shall commence as -on the date of making payment of the Software by the Licensee to the Licensor, -and shall continue until terminated by either party. - -(b)The Licensor retains the right to terminate the license at any time, if the -Licensee is not abiding by any of the terms of the Agreement. The Licensee may -terminate the Agreement at any time at its own discretion by uninstalling the -Software and /or by destroying the said Software (or any copies thereof). -However, the Licensee shall not be entitled to seek any refund of the amount -paid by it to the Licensor, under any circumstances. - -(c)Survival. In the event this Agreement is terminated for any reason, the -provisions set forth in Sections 2(a), 2(b), and 2(c) shall survive. - - -6.INDEMNIFICATION. - -The Licensee release the Licensor from, and agree to indemnify, defend and -hold harmless the Licensor (and its officers, directors, employees, agents and -Affiliates) against, any claim, loss, damage, settlement, cost, taxes, expense -or other liability (including, without limitation, attorneys' fees) (each, a -"Claim") arising from or related to: (a) any actual or alleged breach of any -obligations in this Agreement; (b) any refund, adjustment, or return of -Software,(c) any claim for actual or alleged infringement of any Intellectual -Property Rights made by any third party or damages related thereto; or (d) -Taxes. - - -7.LIMITATION OF LIABILITY. - -The Licensor will not be liable for any direct, indirect, incidental, special, -consequential or exemplary damages, including but not limited to, damages for -loss of profits, goodwill, use, data or other intangible losses arising out of -or in connection with the Software, whether in contract, warranty, tort etc. ( -including negligence, software liability, any type of civil responsibility or -other theory or otherwise) to the Licensee or any other person for cost of -software, cover, recovery or recoupment of any investment made by the Licensee -or its affiliates in connection with this Agreement, or for any other loss of -profit, revenue, business, or data or punitive or consequential damages -arising out of or relating to this Agreement. Further, the aggregate liability -of the Licensor, arising out of or in connection with this Agreement or the -transactions contemplated hereby will not exceed at any time, or under any -circumstances, the total amounts received by the Licensor from the Licensee in -connection with the particular software giving rise to the claim. - - -8.FORCE MAJEURE. - -The Licensor will not be liable for any delay or failure to perform any of its -obligations under this Agreement by reasons, events or other matters beyond -its reasonable control. - - -9.RELATIONSHIP OF PARTIES. - -The Licensor and Licensee are independent legal entities, and nothing in this -Agreement will be construed to create a partnership, joint venture, -association of persons, agency, franchise, sales representative, or employment -relationship between the parties. The Licensee will have no authority to make -or accept any offers or representations on behalf of the Licensor. The -relationship between the parties is that of Licensor and Licensee only, and -the rights, duties, liabilities of each party shall be governed by this -Agreement. - - -10.MODIFICATION. - -The Licensor may amend any of the terms and conditions contained in this -Agreement at any time and solely at its discretion. Any changes will be -effective upon the posting of such changes on the Portal/ website, and the -Licensee is responsible for reviewing these changes and informing itself of -all applicable changes or notices. The continued use of a software by the -Licensee after posting of any changes by the Licensor, will constitute the -acceptance of such changes or modifications by the Licensee. - - -11.MISCELLANEOUS. - -(a)General Provisions. This Agreement: (i) may be amended only by a writing -signed by each of the parties; (ii) may be executed in several counterparts, -each of which shall be deemed an original but all of which shall constitute -one and the same instrument; (iii) contains the entire agreement of the -parties with respect to the transactions contemplated hereby and supersedes -all prior written and oral agreements, and all contemporaneous oral -agreements, relating to such transactions; (iv) shall be governed by, and -construed and enforced in accordance with, the laws of India; and (v) shall be -binding upon, and inure to the benefit of, the parties and their respective -successors and permitted assigns. Each of the parties hereby irrevocably -submits to the jurisdiction of the Courts at Delhi, India, for the purposes of -any action or proceeding arising out of or relating to this Agreement or the -subject matter hereof and brought by any other party. - -(b)Assignment. Except for the purpose of customization as mentioned in clause -2(b)(iv) above, Licensee cannot assign, pledge or otherwise transfer, whether -by operation of law or otherwise, this Agreement, or any of its obligations -hereunder, without the prior written consent of Licensor, which consent shall -not be unreasonably withheld. - -(c)Notices. Unless otherwise specifically provided herein, all notices, -consents, requests, demands and other communications required or permitted -hereunder: - -(i)shall be in writing; - -(ii)shall be sent by messenger, certified or registered mail/email, or -reliable express delivery service, to the appropriate address(es) set forth -below; and - -(iii)shall be deemed to have been given on the date of receipt by the -addressee, as evidenced by a receipt executed by the addressee (or a -responsible person in his or her office), the records of the Party delivering -such communication or a notice to the effect that such addressee refused to -claim or accept such communication, if sent by messenger, mail or express -delivery service. - -All such communications shall be sent to the following addresses or numbers, -or to such other addresses or numbers as any party may inform the others by -giving five days' prior notice: - -If to Webkul Software Pvt. Ltd.: - -Webkul Software Pvt. Ltd. -A-67, Sector 63, NOIDA – 201301, -Uttar Pradesh, India - -If to Licensee: -At the address mentioned by the Licensee -(at the time of placing order of generating Invoice) - -(d)Severability. It is the intent of the parties that the provisions of this -Agreement be enforced to the fullest extent permissible under the laws and -public policies of India in which enforcement hereof is sought. In -furtherance of the foregoing, each provision hereof shall be severable from -each other provision, and any provision hereof which is/ becomes unenforceable -shall be subject to the following: (i) if such provision is contrary to or -conflicts with any requirement of any statute, rule or regulation in effect, -then such requirement shall be incorporated into, or substituted for, such -unenforceable provision to the minimum extent necessary to make such provision -enforceable; (ii) the court, agency or arbitrator considering the matter is -hereby authorized to (or, if such court, agency or arbitrator is unwilling or -fails to do so, then the parties shall) amend such provision to the minimum -extent necessary to make such provision enforceable, and the parties hereby -consent to the entry of an order so amending such provision; and (iii) if -any such provision cannot be or is not reformed and made enforceable pursuant -to clause (i) or (ii) above, then such provision shall be ineffective to the -minimum extent necessary to make the remainder of this Agreement enforceable. -Any application of the foregoing provisions to any provision hereof shall not -effect the validity or enforceability of any other provision hereof. - -(e)By purchasing the Software, the Licensee acknowledge that it has read this -Agreement, and that it agrees to the content of the Agreement, its terms and -agree to use the Software in compliance with this Agreement. - -(f)The Licensor holds the sole copyright of the Software. The Software or any -portion thereof is a copyrightable matter and is liable to be protected by the -applicable laws. Copyright infringement in any manner can lead to prosecution -according to the current law. The Licensor reserves the right to revoke the -license of any user who is not holding any license or is holding an invalid -license. - -(g)This Agreement gives the right to use only one copy of the Software on one -domain solely for the own personal or business use of the Licensee, subject to -all the terms and conditions of this Agreement. A separate License has to be -purchased for each new Software installation. Any distribution of the Software -without the written consent of the Licensor (including non-commercial -distribution) is regarded as violation of this Agreement, and will entail -immediate termination of the Agreement and may invite liability, both civil -and criminal, as per applicable laws. - -(h)The Licensor reserves the rights to publish a selected list of users/ -Licensees of its Software, and no permission of any Licensee is needed in this -regard. The Licensee agrees that the Licensor may, in its sole discretion, -disclose or make available any information provided or submitted by the -Licensee or related to it under this Agreement to any judicial, -quasi-judicial, governmental, regulatory or any other authority as may be -required by the Licensor to co-operate and / or comply with any of their -orders, instructions or directions or to fulfill any requirements under -applicable Laws. - -(i)If the Licensee continues to use the Software even after the sending of the -notice by the Licensor for termination, the Licensee agree to accept an -injunction to restrain itself from its further use, and to pay all costs ( -including but not limited to reasonable attorney fees) to enforce injunction -or to revoke the License, and any damages suffered by the Licensor because of -the misuse of the Software by the Licensee. - - -12.ARBITRATION. - -If any dispute arises between the Licensor and the Licensee at any time, in -connection with the validity, interpretation, implementation or alleged breach -of any provision of this Agreement, the same shall be referred to a sole -Arbitrator who shall be an independent and neutral third party appointed -exclusively by the Licensor. The Licensee shall not object to the appointment -of the Arbitrator so appointed by the Licensor. The place of arbitration shall -be Delhi, India. The Arbitration & Conciliation Act, 1996 as amended by The -Arbitration & Conciliation (Amendment) Act, 2015, shall govern the -arbitration proceedings. The arbitration proceedings shall be held in the -English language. - - -This document is an electronic record in terms of Information Technology Act, -2000 and the amended provisions pertaining to electronic records in various -statutes as amended by the Information Technology Act, 2000. This electronic -record is generated by a computer system and does not require any physical or -digital signatures. \ No newline at end of file diff --git a/odex25_donation/affiliate_management/__manifest__.py b/odex25_donation/affiliate_management/__manifest__.py index 236235896..1d071ee79 100644 --- a/odex25_donation/affiliate_management/__manifest__.py +++ b/odex25_donation/affiliate_management/__manifest__.py @@ -14,72 +14,62 @@ # If not, see ################################################################################# { - "name" : "Odoo Affiliate Management", - "summary" : """Affiliate extension for odoo E-commerce store""", - "category" : "Website", - "version" : "1.0.7", - "sequence" : 1, - "author" : "Webkul Software Pvt. Ltd.", - "license" : "Other proprietary", - "maintainer" : "Saurabh Gupta", - "website" : "https://store.webkul.com/Odoo-Affiliate-Management.html", - "description" : """Odoo Affiliate Extension for Affiliate Management""", - "live_test_url" : "http://odoodemo.webkul.com/?module=affiliate_management&lifetime=90&lout=1&custom_url=/", - "depends" : [ - 'sales_team', - 'website_sale', - 'wk_wizard_messages', - 'web', - 'web_tour', - 'auth_signup', - 'account', - 'base' - ], - "data" : [ - 'security/affiliate_security.xml', - 'security/ir.model.access.csv', - 'views/affiliate_pragram_form_view.xml', - 'data/automated_scheduler_action.xml', - 'views/affiliate_manager_view.xml', - 'data/sequence_view.xml', - 'views/account_invoice_inherit.xml', - 'views/affiliate_visit_view.xml', - 'views/affiliate_config_setting_view.xml', - 'views/res_users_inherit_view.xml', - 'views/affiliate_tool_view.xml', - 'views/affiliate_image_view.xml', - 'views/advance_commision_view.xml', - 'views/affiliate_pricelist_view.xml', - 'views/affiliate_banner_view.xml', - 'views/report_template.xml', - 'views/payment_template.xml', - 'views/index_template.xml', - 'views/tool_template.xml', - 'views/header_template.xml', - 'views/footer_template.xml', - 'views/join_email_template.xml', - 'views/signup_template.xml', - 'views/affiliate_request_view.xml', - 'views/welcome_mail_tepmlate.xml', - 'views/reject_mail_template.xml', - 'views/tool_product_link_template.xml', - 'views/about_template.xml', - 'data/default_affiliate_program_data.xml', - ], - "assets" : { - "web.assets_backend" : [], - "web.assets_frontend" : [ - - 'affiliate_management/static/src/css/website_affiliate.css', - 'affiliate_management/static/src/js/validation.js', - - ] - }, - - "demo" : ['data/demo_data_view.xml'], - "images" : ['static/description/banner.gif'], - "application" : True, - "installable" : True, - "price" : 99, - "currency" : "USD", + "name": "Odoo Affiliate Management", + "summary": """Affiliate extension for odoo E-commerce store""", + "category": "Website", + "version": "1.0.7", + "sequence": 1, + "author": "Webkul Software Pvt. Ltd.", + "license": "Other proprietary", + "maintainer": "Saurabh Gupta", + "website": "https://store.webkul.com/Odoo-Affiliate-Management.html", + "description": """Odoo Affiliate Extension for Affiliate Management""", + "live_test_url": "http://odoodemo.webkul.com/?module=affiliate_management&lifetime=90&lout=1&custom_url=/", + "depends": [ + 'sales_team', + 'website_sale', + 'web', + 'web_tour', + 'auth_signup', + 'account', + 'base' + ], + "data": [ + 'security/affiliate_security.xml', + 'security/ir.model.access.csv', + 'views/affiliate_pragram_form_view.xml', + 'data/automated_scheduler_action.xml', + 'views/affiliate_manager_view.xml', + 'data/sequence_view.xml', + 'views/account_invoice_inherit.xml', + 'views/affiliate_visit_view.xml', + 'views/affiliate_config_setting_view.xml', + 'views/res_users_inherit_view.xml', + 'views/affiliate_tool_view.xml', + 'views/affiliate_image_view.xml', + 'views/advance_commision_view.xml', + 'views/affiliate_pricelist_view.xml', + 'views/affiliate_banner_view.xml', + 'views/report_template.xml', + 'views/payment_template.xml', + 'views/index_template.xml', + 'views/tool_template.xml', + 'views/header_template.xml', + 'views/footer_template.xml', + 'views/join_email_template.xml', + 'views/signup_template.xml', + 'views/affiliate_request_view.xml', + 'views/welcome_mail_tepmlate.xml', + 'views/reject_mail_template.xml', + 'views/tool_product_link_template.xml', + 'views/about_template.xml', + 'data/default_affiliate_program_data.xml', + 'views/assets.xml' + ], + "demo": ['data/demo_data_view.xml'], + "images": ['static/description/banner.gif'], + "application": True, + "installable": True, + "price": 99, + "currency": "USD", } diff --git a/odex25_donation/affiliate_management/_q b/odex25_donation/affiliate_management/_q deleted file mode 100644 index 20f7cec46..000000000 --- a/odex25_donation/affiliate_management/_q +++ /dev/null @@ -1,311 +0,0 @@ -diff --git a/static/description/index.html b/static/description/index.html -index adf3754..4b261ec 100644 ---- a/static/description/index.html -+++ b/static/description/index.html -@@ -20,7 +20,7 @@ -  -
 -
 --
Affiliate Management in Odoo for marketing on another level!
 -+
Affiliate Management in Odoo for marketing on another level!
 -
 -
 -
 -@@ -58,7 +58,7 @@ -  -
 -
 --
Hassle-free way for Affiliate Management in Odoo
 -+
Hassle-free way for Affiliate Management in Odoo
 -
 -
 -
 -@@ -425,6 +425,288 @@ -  -  -

 -+
 -+
 -+
 -+

Our Other Apps

 -+
 -+
 -+ Make your eCommerce Experience more better with our other Apps. -+
 -+
 -+
 -+
 -+  -+
 -+
 -+
 -+
 -+
 -  -
 -
 diff --git a/odex25_donation/affiliate_management/changelog.md b/odex25_donation/affiliate_management/changelog.md deleted file mode 100644 index 7ca9aa03b..000000000 --- a/odex25_donation/affiliate_management/changelog.md +++ /dev/null @@ -1,11 +0,0 @@ -=>Affiliate Management technical name 'affiliate_management' -[version:1.0.1] Date : 30-10-2017 - *[IMPROVEMENT] - - improvement in Generate banner (in product search) - *[FIX] - - replace a (select a category) to (all categories) in category dropdown in views/tool_product_link_template.xml - *[ADD] - - - *[change] - -version from 1.0.0 to 1.0.1 in manifest - *[remove] \ No newline at end of file diff --git a/odex25_donation/affiliate_management/controllers/affiliate_website.py b/odex25_donation/affiliate_management/controllers/affiliate_website.py index be78c79c8..feeb747aa 100644 --- a/odex25_donation/affiliate_management/controllers/affiliate_website.py +++ b/odex25_donation/affiliate_management/controllers/affiliate_website.py @@ -13,6 +13,16 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo.addons.website.controllers.main import Website, QueryURL +from odoo.osv import expression +from odoo.addons.website_sale.controllers.main import WebsiteSale +from odoo.addons.affiliate_management.controllers.home import Home +from odoo.addons.web.controllers.main import ensure_db, _get_login_redirect_url +import requests +from odoo.addons.website_sale.controllers.main import TableCompute +import werkzeug.wrappers +import werkzeug.utils +from odoo.fields import Date from ast import literal_eval from odoo.addons.auth_signup.models.res_users import SignupError from odoo import http @@ -21,26 +31,14 @@ from odoo import tools from odoo.tools.translate import _ import logging _logger = logging.getLogger(__name__) -from odoo.fields import Date -import werkzeug.utils -import werkzeug.wrappers -from odoo.addons.website_sale.controllers.main import TableCompute -import requests # from odoo.addons.web.controllers.main import db_monodb, ensure_db, set_cookie_and_redirect, login_and_redirect -from odoo.addons.web.controllers.utils import ensure_db, _get_login_redirect_url -from odoo.addons.affiliate_management.controllers.home import Home -from odoo.addons.website.controllers.main import Website,QueryURL # from odoo.addons.website_form.controllers.main import WebsiteForm -from odoo.addons.website_sale.controllers.main import WebsiteSale -from odoo.osv import expression - class website_affiliate(Home): - - #home page of affiliate website - @http.route('/affiliate/', auth='public',type='http', website=True) + # home page of affiliate website + @http.route('/affiliate/', auth='public', type='http', website=True) def affiliate(self, **kw): banner = request.env['affiliate.banner'].sudo().search([]) banner_title = banner[-1].banner_title if banner else '' @@ -52,33 +50,33 @@ class website_affiliate(Home): how_it_work_title = ConfigValues.get('work_title') how_it_work_text = tools.html_sanitize(ConfigValues.get('work_text')) values = { - 'default_header':False, - 'affiliate_website':True, - 'banner_title':banner_title, - 'banner_image':banner_image, - 'enable_forget_pwd':enable_forget_pwd, - 'enable_login':enable_login, - 'enable_signup':enable_signup, - 'website_name' : request.env['website'].search([])[0].name, - 'how_it_work_title':how_it_work_title, - 'how_it_work_text' :how_it_work_text + 'default_header': False, + 'affiliate_website': True, + 'banner_title': banner_title, + 'banner_image': banner_image, + 'enable_forget_pwd': enable_forget_pwd, + 'enable_login': enable_login, + 'enable_signup': enable_signup, + 'website_name': request.env['website'].search([])[0].name, + 'how_it_work_title': how_it_work_title, + 'how_it_work_text': how_it_work_text } if request.session.get('error'): - values.update({'error':request.session.get('error')}) + values.update({'error': request.session.get('error')}) if request.session.get('success'): - values.update({'success':request.session.get('success')}) + values.update({'success': request.session.get('success')}) request.session.pop('error', None) request.session.pop('success', None) return http.request.render('affiliate_management.affiliate', values) - @http.route('/affiliate/join', auth='public',type='json', website=True,methods=['POST']) - def join(self,email ,**kw): + @http.route('/affiliate/join', auth='public', type='json', website=True, methods=['POST']) + def join(self, email, **kw): msg = False - aff = request.env['affiliate.request'].sudo().search([('name','=',email)]) + aff = request.env['affiliate.request'].sudo().search([('name', '=', email)]) if aff: if (not aff.signup_valid) and (not aff.user_id): aff.regenerate_token() - msg = "Thank you for registering with us, we have sent you the Signup mail at "+email+"." + msg = "Thank you for registering with us, we have sent you the Signup mail at " + email + "." else: if aff.state == 'aproove': @@ -92,65 +90,64 @@ class website_affiliate(Home): msg = "We have already sended you a joining e-mail" else: - user = request.env['res.users'].sudo().search([('login','=',email)]) - msg = "Thank you for registering with us, we have sent you the Signup mail at "+email + user = request.env['res.users'].sudo().search([('login', '=', email)]) + msg = "Thank you for registering with us, we have sent you the Signup mail at " + email vals = { - 'name':email, - 'state':'draft', + 'name': email, + 'state': 'draft', } if user: vals.update({ - "partner_id":user.partner_id.id, - "user_id" : user.id, - 'state' : 'register' + "partner_id": user.partner_id.id, + "user_id": user.id, + 'state': 'register' }) msg = "Your request is pending for approval with us, soon you will receive 'Approval' confirmation e-mail." aff_request = request.env['affiliate.request'].sudo().create(vals) return msg - @http.route('/affiliate/about',type='http', auth="user", website=True) + @http.route('/affiliate/about', type='http', auth="user", website=True) def affiliate_about(self, **kw): partner = request.env.user.partner_id base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') currency_id = request.env.user.company_id.currency_id ConfigValues = request.env['res.config.settings'].sudo().website_constant() db = request.session.get('db') - value={ - 'url': "%s/shop?aff_key=%s&db=%s" %(base_url,partner.res_affiliate_key,db), - 'affiliate_key': partner.res_affiliate_key, - 'pending_amt':partner.pending_amt, - 'approved_amt':partner.approved_amt, - 'currency_id':currency_id, - 'how_it_works_title':ConfigValues.get('work_title'), - 'how_it_works_text':tools.html_sanitize(ConfigValues.get('work_text')), + value = { + 'url': "%s/shop?aff_key=%s&db=%s" % (base_url, partner.res_affiliate_key, db), + 'affiliate_key': partner.res_affiliate_key, + 'pending_amt': partner.pending_amt, + 'approved_amt': partner.approved_amt, + 'currency_id': currency_id, + 'how_it_works_title': ConfigValues.get('work_title'), + 'how_it_works_text': tools.html_sanitize(ConfigValues.get('work_text')), } return http.request.render('affiliate_management.about', value) - @http.route('/affiliate/signup', auth='public',type='http', website=True) + @http.route('/affiliate/signup', auth='public', type='http', website=True) def register(self, **kw): token = request.httprequest.args.get('token') - user = request.env['affiliate.request'].sudo().search([('signup_token','=',token)]) + user = request.env['affiliate.request'].sudo().search([('signup_token', '=', token)]) term_condition = request.env['res.config.settings'].sudo().website_constant().get('term_condition') values = {} if user.signup_valid and user.state == 'draft': values .update({ - 'name': user.name.split('@')[0], - 'login': user.name, - 'token': token, - 'term_condition':tools.html_sanitize(term_condition), - }) + 'name': user.name.split('@')[0], + 'login': user.name, + 'token': token, + 'term_condition': tools.html_sanitize(term_condition), + }) if request.session.get('error'): - values.update({'error':request.session.get('error')}) + values.update({'error': request.session.get('error')}) else: pass request.session.pop('error', None) - return http.request.render('affiliate_management.register',values) + return http.request.render('affiliate_management.register', values) - - @http.route('/affiliate/register', auth='public',type='http', website=True) + @http.route('/affiliate/register', auth='public', type='http', website=True) def register_affiliate(self, **kw): ensure_db() - aff_request = request.env['affiliate.request'].sudo().search([('name','=',kw.get('login'))]) + aff_request = request.env['affiliate.request'].sudo().search([('name', '=', kw.get('login'))]) if aff_request and kw.get('confirm_password') == kw.get('password') and aff_request.signup_token == kw.get('token'): template_user_id = literal_eval(request.env['ir.config_parameter'].sudo().get_param('base.template_portal_user_id', 'False')) template_user = request.env['res.users'].sudo().browse(template_user_id) @@ -159,16 +156,16 @@ class website_affiliate(Home): raise SignupError('Invalid template user.') data = kw redirect_url = "/" - values = { key: data.get(key) for key in ('login', 'name') } + values = {key: data.get(key) for key in ('login', 'name')} values['email'] = data.get('email') or values.get('login') values['lang'] = request.lang.code values['active'] = True no_invitation_mail = True - values['password'] = data.get('password',"") + values['password'] = data.get('password', "") try: with request.env.cr.savepoint(): - user = template_user.with_context(no_reset_password = no_invitation_mail).copy(values) - _logger.info('------user.partner--%r-----',user.partner_id) + user = template_user.with_context(no_reset_password=no_invitation_mail).copy(values) + _logger.info('------user.partner--%r-----', user.partner_id) # update phoen no. and comment in res.partner user.partner_id.comment = kw.get('comment') user.partner_id.phone = kw.get('phone') @@ -181,60 +178,58 @@ class website_affiliate(Home): if auto_approve_request: aff_request.action_aproove() db = request.env.cr.dbname - uid = request.session.authenticate(request.session.db, data.get('email') or values.get('login'), data.get('password',"")) + uid = request.session.authenticate(request.session.db, data.get('email') or values.get('login'), data.get('password', "")) # request.params['login_success'] = True - _logger.info("=================uid====%r",uid) + _logger.info("=================uid====%r", uid) return request.redirect(_get_login_redirect_url(uid, redirect='/affiliate')) # return login_and_redirect(db, data['login'], data['password'],redirect_url='/affiliate') # return _get_login_redirect_url(user.id,redirect='/affiliate') except Exception as e: - _logger.error("Error123: %r"%e) + _logger.error("Error123: %r" % e) return request.redirect('/') else: - if kw.get('password')!= kw.get('confirm_password'): - request.session['error']= "Passwords Does't match." - return request.redirect('/affiliate/signup?token='+kw.get('token'), 303) + if kw.get('password') != kw.get('confirm_password'): + request.session['error'] = "Passwords Does't match." + return request.redirect('/affiliate/signup?token=' + kw.get('token'), 303) else: - request.session['error']= "something went wrong.." + request.session['error'] = "something went wrong.." return request.redirect('/affiliate/', 303) - @http.route('/affiliate/register/confirmation', auth='public',type='http', website=True) + @http.route('/affiliate/register/confirmation', auth='public', type='http', website=True) def register_affiliate_confirmation(self, **kw): return http.request.render('affiliate_management.confirmation', { }) - - @http.route('/affiliate/home',type='http', auth="user", website=True) + @http.route('/affiliate/home', type='http', auth="user", website=True) def home(self, **kw): return http.request.render('affiliate_management.report', { }) - @http.route('/affiliate/report', type='http', auth="user", website=True) def report(self, **kw): partner = request.env.user.partner_id enable_ppc = request.env['res.config.settings'].sudo().website_constant().get('enable_ppc') currency_id = request.env.user.company_id.currency_id visits = request.env['affiliate.visit'].sudo() - ppc_visit = visits.search([('affiliate_method','=','ppc'),('affiliate_partner_id','=',partner.id),'|',('state','=','invoice'),('state','=','confirm')]) - pps_visit = visits.search([('affiliate_method','=','pps'),('affiliate_partner_id','=',partner.id),'|',('state','=','invoice'),('state','=','confirm')]) + ppc_visit = visits.search([('affiliate_method', '=', 'ppc'), ('affiliate_partner_id', '=', partner.id), '|', ('state', '=', 'invoice'), ('state', '=', 'confirm')]) + pps_visit = visits.search([('affiliate_method', '=', 'pps'), ('affiliate_partner_id', '=', partner.id), '|', ('state', '=', 'invoice'), ('state', '=', 'confirm')]) values = { - 'pending_amt':partner.pending_amt, - 'approved_amt':partner.approved_amt, - 'ppc_count':len(ppc_visit), - 'pps_count':len(pps_visit), - 'enable_ppc':enable_ppc, - "currency_id":currency_id, + 'pending_amt': partner.pending_amt, + 'approved_amt': partner.approved_amt, + 'ppc_count': len(ppc_visit), + 'pps_count': len(pps_visit), + 'enable_ppc': enable_ppc, + "currency_id": currency_id, } return http.request.render('affiliate_management.report', values) - @http.route(['/my/traffic','/my/traffic/page/'], type='http', auth="user", website=True) + @http.route(['/my/traffic', '/my/traffic/page/'], type='http', auth="user", website=True) def traffic(self, page=1, date_begin=None, date_end=None, **kw): - values={} + values = {} partner = request.env.user.partner_id visits = request.env['affiliate.visit'].sudo() - domain = [('affiliate_partner_id','=',partner.id),('affiliate_method','=','ppc'),'|',('state','=','invoice'),('state','=','confirm')] + domain = [('affiliate_partner_id', '=', partner.id), ('affiliate_method', '=', 'ppc'), '|', ('state', '=', 'invoice'), ('state', '=', 'confirm')] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] traffic_count = visits.search_count(domain) @@ -254,23 +249,20 @@ class website_affiliate(Home): return http.request.render('affiliate_management.affiliate_traffic', values) - @http.route(['/my/traffic/'], type='http', auth="user", website=True) def aff_traffic_form(self, traffic=None, **kw): traffic_visit = request.env['affiliate.visit'].sudo().browse([traffic]) return request.render("affiliate_management.traffic_form", { 'traffic_detail': traffic_visit, - 'product_detail':request.env['product.product'].browse([traffic_visit.type_id]), + 'product_detail': request.env['product.product'].browse([traffic_visit.type_id]), }) - - - @http.route(['/my/order','/my/order/page/'], type='http', auth="user", website=True) + @http.route(['/my/order', '/my/order/page/'], type='http', auth="user", website=True) def aff_order(self, page=1, date_begin=None, date_end=None, **kw): - values={} + values = {} partner = request.env.user.partner_id visits = request.env['affiliate.visit'].sudo() - domain = [('affiliate_partner_id','=',partner.id),('affiliate_method','=','pps'),'|',('state','=','invoice'),('state','=','confirm')] + domain = [('affiliate_partner_id', '=', partner.id), ('affiliate_method', '=', 'pps'), '|', ('state', '=', 'invoice'), ('state', '=', 'confirm')] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] traffic_count = visits.search_count(domain) @@ -289,23 +281,21 @@ class website_affiliate(Home): }) return http.request.render('affiliate_management.affiliate_order', values) - @http.route(['/my/order/'], type='http', auth="user", website=True) def aff_order_form(self, order=None, **kw): order_visit = request.env['affiliate.visit'].sudo().browse([order]) return request.render("affiliate_management.order_form", { 'order_visit_detail': order_visit, - 'product_detail' :order_visit.sales_order_line_id.sudo() + 'product_detail': order_visit.sales_order_line_id.sudo() }) - # Routes for the payment template - @http.route(['/affiliate/payment','/affiliate/payment/page/'], type='http', auth="user", website=True) + @http.route(['/affiliate/payment', '/affiliate/payment/page/'], type='http', auth="user", website=True) def payment(self, page=1, date_begin=None, date_end=None, **kw): - values={} + values = {} partner = request.env.user.partner_id invoices = request.env['account.move'] - domain = [('partner_id','=',partner.id),('payment_state','=','paid'),('ref','=',None)] + domain = [('partner_id', '=', partner.id), ('payment_state', '=', 'paid'), ('ref', '=', None)] if date_begin and date_end: domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] invoice_count = invoices.search_count(domain) @@ -324,8 +314,7 @@ class website_affiliate(Home): 'invoices': invoice_list, 'default_url': '/affiliate/payment', }) - return http.request.render('affiliate_management.payment_tree',values ) - + return http.request.render('affiliate_management.payment_tree', values) @http.route(['/my/invoice/'], type='http', auth="user", website=True) def aff_invoice_form(self, invoice=None, **kw): @@ -335,49 +324,48 @@ class website_affiliate(Home): }) - @http.route('/affiliate/tool', auth='user',type='http', website=True) + @http.route('/affiliate/tool', auth='user', type='http', website=True) def tool(self, **kw): """actions for Tool "affiliate/tool""" - return http.request.render('affiliate_management.tool',{}) + return http.request.render('affiliate_management.tool', {}) - - @http.route('/tool/create_link', auth='user',type='http', website=True) + @http.route('/tool/create_link', auth='user', type='http', website=True) def create_link(self, **kw): """generate affiliate link by url""" partner = request.env.user.partner_id - # link = kw.get("link") - link = kw.get("link") if kw.get("link").find('#') != -1 else str(kw.get("link"))+'#' + # link = kw.get("link") + link = kw.get("link") if kw.get("link").find('#') != -1 else str(kw.get("link")) + '#' index_li = link.find('#') db = request.session.get('db') - db = "?db=%s" %(db) - link = link[:index_li]+db+link[index_li:] + db = "?db=%s" % (db) + link = link[:index_li] + db + link[index_li:] result = self.check_link_validation(link) if kw.get('link') and partner.res_affiliate_key and result: index_li = link.find('#') - request.session['generate_link'] = link[:index_li]+'&aff_key='+partner.res_affiliate_key+link[index_li:] + request.session['generate_link'] = link[:index_li] + '&aff_key=' + partner.res_affiliate_key + link[index_li:] return request.redirect('/tool/link_generator/', 303) - @http.route("/tool/link_generator", auth='user',type='http', website=True) + @http.route("/tool/link_generator", auth='user', type='http', website=True) def link_generator(self, **kw): partner = request.env.user.partner_id - values={} + values = {} if request.session.get('generate_link'): values.update({ - 'generate_link':request.session.get('generate_link'), - 'error':request.session.get('error') - }) + 'generate_link': request.session.get('generate_link'), + 'error': request.session.get('error') + }) if request.session.get('error'): values.update({ - 'error':request.session.get('error') - }) + 'error': request.session.get('error') + }) request.session.pop('generate_link', None) request.session.pop('error', None) - return http.request.render('affiliate_management.link_generator',values) + return http.request.render('affiliate_management.link_generator', values) - def check_link_validation(self,link): + def check_link_validation(self, link): base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') try: - r = requests.get(link,verify=False) + r = requests.get(link, verify=False) if r.status_code == 200: langs = [l.code for l in request.website.language_ids] @@ -386,10 +374,10 @@ class website_affiliate(Home): # if a language is already in the path, remove it if link_arr[1] in langs: link_arr.pop(1) - link_base_url = link_arr[0]+"//"+link_arr[2] + link_base_url = link_arr[0] + "//" + link_arr[2] - if base_url == link_base_url : - #changed by vardaan as product are not showing as part of url + if base_url == link_base_url: + # changed by vardaan as product are not showing as part of url if 'shop' in link_arr or 'product' in link_arr: return True else: @@ -399,113 +387,105 @@ class website_affiliate(Home): request.session['error'] = "Base Url doesn't match" return False else: - request.session['error'] = "Please enter a Valid Url. Bad response from "+link + request.session['error'] = "Please enter a Valid Url. Bad response from " + link return False except Exception as e: - request.session['error'] = "Please enter a Valid Url. + %r"%e + request.session['error'] = "Please enter a Valid Url. + %r" % e return False - - - - @http.route("/tool/product_link", auth='user',type='http', website=True) + @http.route("/tool/product_link", auth='user', type='http', website=True) def product_link(self, **kw): - values={} + values = {} category = request.env['product.public.category'].sudo().search([]) values.update({ 'category': category, - }) - return http.request.render('affiliate_management.product_link',values) - + }) + return http.request.render('affiliate_management.product_link', values) # search the product on criteria category and published product - @http.route("/search/product", auth='user',type='http', website=True) + @http.route("/search/product", auth='user', type='http', website=True) def search_product(self, **kw): domain = request.website.sale_product_domain() if kw.get('name'): domain += [ - ('website_published','=',True),'|', '|', '|', ('name', 'ilike', kw.get('name')), ('description', 'ilike', kw.get('name')), + ('website_published', '=', True), '|', '|', '|', ('name', 'ilike', kw.get('name')), ('description', 'ilike', kw.get('name')), ('description_sale', 'ilike', kw.get('name')), ('product_variant_ids.default_code', 'ilike', kw.get('name'))] if kw.get('categories'): - category_id = request.env['product.public.category'].sudo().search([('name','=',kw.get('categories'))],limit=1) - if category_id: + category_id = request.env['product.public.category'].sudo().search([('name', '=', kw.get('categories'))], limit=1) + if category_id: domain += [('public_categ_ids', 'child_of', int(category_id.id))] partner = request.env.user.partner_id - values={} + values = {} category = request.env['product.public.category'].sudo().search([]) values.update({ 'category': category, - }) + }) product_template = request.env['product.template'].sudo() products = product_template.search(domain) db = request.session.get('db') if products: values.update({ 'bins': TableCompute().process(products, 10), - 'search_products':products, - 'rows':4, + 'search_products': products, + 'rows': 4, 'partner_key': partner.res_affiliate_key, 'base_url': request.env['ir.config_parameter'].sudo().get_param('web.base.url'), - 'db':db - }) + 'db': db + }) # _logger.info("=======values====%r",values) - return http.request.render('affiliate_management.product_link',values) + return http.request.render('affiliate_management.product_link', values) - - @http.route('/tool/generate_banner', auth='user',type='http', website=True) + @http.route('/tool/generate_banner', auth='user', type='http', website=True) def tool_banner(self, **kw): partner = request.env.user.partner_id - banner_image_ids = request.env['affiliate.image'].sudo().search([('image_active','=',True)]) - product = request.env['product.template'].sudo().search([('id','=',kw.get('product_id'))]) + banner_image_ids = request.env['affiliate.image'].sudo().search([('image_active', '=', True)]) + product = request.env['product.template'].sudo().search([('id', '=', kw.get('product_id'))]) db = request.session.get('db') - values={ - 'banner_button':banner_image_ids, - 'product':product, - 'db':db + values = { + 'banner_button': banner_image_ids, + 'product': product, + 'db': db } - return http.request.render('affiliate_management.generate_banner',values) + return http.request.render('affiliate_management.generate_banner', values) - - @http.route("/tool/generate_button_link", auth='user',type='http', website=True) + @http.route("/tool/generate_button_link", auth='user', type='http', website=True) def generate_button_link(self, **kw): partner = request.env.user.partner_id base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') db = request.session.get('db') - values ={ + values = { 'partner_key': partner.res_affiliate_key, - 'product_id':kw.get('product_id'), - 'base_url' : base_url, - 'db':db + 'product_id': kw.get('product_id'), + 'base_url': base_url, + 'db': db } - selected_image= kw.get('choose_banner').split("_") + selected_image = kw.get('choose_banner').split("_") if selected_image[0] == 'button': - _logger.info("-----selected button image id ---%r---",selected_image[1]) + _logger.info("-----selected button image id ---%r---", selected_image[1]) button = request.env['affiliate.image'].sudo().browse([int(selected_image[1])]) values.update({ - "button":button - }) + "button": button + }) else: if selected_image[0] == 'product': values.update({ - "is_product":True + "is_product": True }) - _logger.info("-----selected product image id ---%r---",selected_image[1]) - return http.request.render('affiliate_management.generate_button_link',values) - - + _logger.info("-----selected product image id ---%r---", selected_image[1]) + return http.request.render('affiliate_management.generate_button_link', values) @http.route("/affiliate/request", type='json', auth="public", methods=['POST'], website=True) - def portal_user(self, user_id,**kw): + def portal_user(self, user_id, **kw): User = request.env['res.users'].sudo().browse([request.uid]) AffRqstObj = request.env['affiliate.request'].sudo() - vals ={ - 'name':User.partner_id.email, - 'partner_id': User.partner_id.id, - 'user_id': request.uid, - 'state':'register', + vals = { + 'name': User.partner_id.email, + 'partner_id': User.partner_id.id, + 'user_id': request.uid, + 'state': 'register', } aff_request = AffRqstObj.create(vals) auto_approve_request = request.env['res.config.settings'].sudo().website_constant().get('auto_approve_request') diff --git a/odex25_donation/affiliate_management/controllers/home.py b/odex25_donation/affiliate_management/controllers/home.py index 7811da433..9f1869ceb 100644 --- a/odex25_donation/affiliate_management/controllers/home.py +++ b/odex25_donation/affiliate_management/controllers/home.py @@ -13,6 +13,10 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo.tools.translate import _ +import odoo.modules.registry +import odoo +from odoo.addons.web.controllers.main import Home import werkzeug.utils import werkzeug.wrappers @@ -21,12 +25,7 @@ from odoo.http import request import logging _logger = logging.getLogger(__name__) -from odoo.addons.web.controllers.home import Home -import odoo -import odoo.modules.registry -from odoo.tools.translate import _ -from odoo.http import request class Home(Home): @@ -34,10 +33,10 @@ class Home(Home): def web_login(self, redirect=None, *args, **kw): response = super(Home, self).web_login(redirect=redirect, *args, **kw) # kw.get('affiliate_login_form') is hidden field in login form of affiliate home page - check_affiliate = request.env['res.users'].sudo().search([('login','=',kw.get('login'))]).partner_id.is_affiliate + check_affiliate = request.env['res.users'].sudo().search([('login', '=', kw.get('login'))]).partner_id.is_affiliate if kw.get('affiliate_login_form') and response.qcontext.get('error'): - request.session['error']= 'Wrong login/password' - return request.redirect('/affiliate/',303) + request.session['error'] = 'Wrong login/password' + return request.redirect('/affiliate/', 303) else: if kw.get('affiliate_login_form') and check_affiliate: return super(Home, self).web_login(redirect='/affiliate/about', *args, **kw) diff --git a/odex25_donation/affiliate_management/controllers/main.py b/odex25_donation/affiliate_management/controllers/main.py index e72140178..e139d088a 100644 --- a/odex25_donation/affiliate_management/controllers/main.py +++ b/odex25_donation/affiliate_management/controllers/main.py @@ -13,38 +13,37 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +import datetime +from odoo.addons.website_sale.controllers.main import WebsiteSale from odoo import http from odoo.http import request from odoo import fields import logging _logger = logging.getLogger(__name__) -from odoo.addons.website_sale.controllers.main import WebsiteSale -import datetime class WebsiteSale(WebsiteSale): - def create_aff_visit_entry(self,vals): - ppc_exist = self.check_ppc_exist(vals) - if ppc_exist: - visit = ppc_exist - else: - visit = request.env['affiliate.visit'].sudo().create(vals) - return visit - - - def check_ppc_exist(self,vals): - domain = [('type_id','=',vals['type_id']),('affiliate_method','=',vals['affiliate_method']),('affiliate_key','=',vals['affiliate_key']),('ip_address','=',vals['ip_address'])] - visit = request.env['affiliate.visit'].sudo().search(domain) - check_unique_ppc = request.env['res.config.settings'].sudo().website_constant().get('unique_ppc_traffic') - # "check_unique_ppc" it cheacks that in config setting wheather the unique ppc is enable or not - if check_unique_ppc: - if visit: - return visit + def create_aff_visit_entry(self, vals): + ppc_exist = self.check_ppc_exist(vals) + if ppc_exist: + visit = ppc_exist else: - return False - else: - return False + visit = request.env['affiliate.visit'].sudo().create(vals) + return visit + + def check_ppc_exist(self, vals): + domain = [('type_id', '=', vals['type_id']), ('affiliate_method', '=', vals['affiliate_method']), ('affiliate_key', '=', vals['affiliate_key']), ('ip_address', '=', vals['ip_address'])] + visit = request.env['affiliate.visit'].sudo().search(domain) + check_unique_ppc = request.env['res.config.settings'].sudo().website_constant().get('unique_ppc_traffic') + # "check_unique_ppc" it cheacks that in config setting wheather the unique ppc is enable or not + if check_unique_ppc: + if visit: + return visit + else: + return False + else: + return False # override shop action in website_sale @http.route([ @@ -52,123 +51,118 @@ class WebsiteSale(WebsiteSale): '/shop/page/', '/shop/category/', '/shop/category//page/' - ], type='http', auth="public", website=True,sitemap=WebsiteSale.sitemap_shop) + ], type='http', auth="public", website=True, sitemap=WebsiteSale.sitemap_shop) def shop(self, page=0, category=None, search='', ppg=False, **post): enable_ppc = request.env['res.config.settings'].sudo().website_constant().get('enable_ppc') expire = False - result = super(WebsiteSale,self).shop(page=page, category=category, search=search, ppg=ppg, **post) + result = super(WebsiteSale, self).shop(page=page, category=category, search=search, ppg=ppg, **post) aff_key = request.httprequest.args.get('aff_key') if category and aff_key: expire = self.calc_cookie_expire_date() path = request.httprequest.full_path - partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key','=',aff_key),('is_affiliate','=',True)]) - vals = self.create_affiliate_visit(aff_key,partner_id,category) - vals.update({'affiliate_type':'category'}) - if ( len(partner_id) == 1): + partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key', '=', aff_key), ('is_affiliate', '=', True)]) + vals = self.create_affiliate_visit(aff_key, partner_id, category) + vals.update({'affiliate_type': 'category'}) + if (len(partner_id) == 1): affiliate_visit = self.create_aff_visit_entry(vals) if enable_ppc else False - result.set_cookie(key='affkey_%s'%(aff_key), value='category_%s'%(category.id),expires=expire) + result.set_cookie(key='affkey_%s' % (aff_key), value='category_%s' % (category.id), expires=expire) else: _logger.info("=====affiliate_visit not created by category===========") else: if aff_key: expire = self.calc_cookie_expire_date() - partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key','=',aff_key),('is_affiliate','=',True)]) + partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key', '=', aff_key), ('is_affiliate', '=', True)]) if partner_id: - result.set_cookie(key='affkey_%s'%(aff_key), value='shop',expires=expire) + result.set_cookie(key='affkey_%s' % (aff_key), value='shop', expires=expire) return result - @http.route(['/shop/'], type='http', auth="public", website=True) def product(self, product, category='', search='', **kwargs): - _logger.info("=====product page=========") - _logger.info("=====product page aff_key==%r=========",request.httprequest.args) - enable_ppc = request.env['res.config.settings'].sudo().website_constant().get('enable_ppc') - expire = self.calc_cookie_expire_date() - result = super(WebsiteSale,self).product(product=product, category=category, search=search, **kwargs) - if request.httprequest.args.get('aff_key'): - # path is the complete url with url = xxxx?aff_key=XXXXXXXX - path = request.httprequest.full_path - # aff_key is fetch from url - aff_key = request.httprequest.args.get('aff_key') - partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key','=',aff_key),('is_affiliate','=',True)]) - vals = self.create_affiliate_visit(aff_key,partner_id,product) - vals.update({'affiliate_type':'product'}) - if ( len(partner_id) == 1): - affiliate_visit = self.create_aff_visit_entry(vals) if enable_ppc else False - # "create_aff_visit_entry " this methods check weather the visit is already created or not or if created return the no. of existing record in object - result.set_cookie(key='affkey_%s'%(aff_key),value='product_%s'%(product.id),expires=expire) - _logger.info("============affiliate_visit created by product==%r=======",affiliate_visit) - else: - _logger.info("=====affiliate_visit not created by product===========%s %s"%(aff_key,partner_id)) - return result - - + _logger.info("=====product page=========") + _logger.info("=====product page aff_key==%r=========", request.httprequest.args) + enable_ppc = request.env['res.config.settings'].sudo().website_constant().get('enable_ppc') + expire = self.calc_cookie_expire_date() + result = super(WebsiteSale, self).product(product=product, category=category, search=search, **kwargs) + if request.httprequest.args.get('aff_key'): + # path is the complete url with url = xxxx?aff_key=XXXXXXXX + path = request.httprequest.full_path + # aff_key is fetch from url + aff_key = request.httprequest.args.get('aff_key') + partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key', '=', aff_key), ('is_affiliate', '=', True)]) + vals = self.create_affiliate_visit(aff_key, partner_id, product) + vals.update({'affiliate_type': 'product'}) + if (len(partner_id) == 1): + affiliate_visit = self.create_aff_visit_entry(vals) if enable_ppc else False + # "create_aff_visit_entry " this methods check weather the visit is already created or not or if created return the no. of existing record in object + result.set_cookie(key='affkey_%s' % (aff_key), value='product_%s' % (product.id), expires=expire) + _logger.info("============affiliate_visit created by product==%r=======", affiliate_visit) + else: + _logger.info("=====affiliate_visit not created by product===========%s %s" % (aff_key, partner_id)) + return result @http.route(['/shop/confirmation'], type='http', auth="public", website=True) def shop_payment_confirmation(self, **post): - result = super(WebsiteSale,self).shop_payment_confirmation(**post) - # here result id http.render argument is http.render{ http.render(template, qcontext=None, lazy=True, **kw) } - sale_order_id = result.qcontext.get('order') - return self.update_affiliate_visit_cookies( sale_order_id,result ) + result = super(WebsiteSale, self).shop_payment_confirmation(**post) + # here result id http.render argument is http.render{ http.render(template, qcontext=None, lazy=True, **kw) } + sale_order_id = result.qcontext.get('order') + return self.update_affiliate_visit_cookies(sale_order_id, result) - - def create_affiliate_visit(self,aff_key,partner_id,type_id): - """ method to delete the cookie after update function on id""" - vals = { - 'affiliate_method':'ppc', - 'affiliate_key':aff_key, - 'affiliate_partner_id':partner_id.id, - 'url':request.httprequest.full_path, - 'ip_address':request.httprequest.environ['REMOTE_ADDR'], - 'type_id':type_id.id, - 'convert_date':fields.datetime.now(), + def create_affiliate_visit(self, aff_key, partner_id, type_id): + """ method to delete the cookie after update function on id""" + vals = { + 'affiliate_method': 'ppc', + 'affiliate_key': aff_key, + 'affiliate_partner_id': partner_id.id, + 'url': request.httprequest.full_path, + 'ip_address': request.httprequest.environ['REMOTE_ADDR'], + 'type_id': type_id.id, + 'convert_date': fields.datetime.now(), 'affiliate_program_id': partner_id.affiliate_program_id.id, } - return vals + return vals - def update_affiliate_visit_cookies(self , sale_order_id ,result): - """update affiliate.visit from cokkies data i.e created in product and shop method""" - cookies = dict(request.httprequest.cookies) - visit = request.env['affiliate.visit'] - arr=[]# contains cookies product_id - for k,v in cookies.items(): - if 'affkey_' in k: - arr.append(k.split('_')[1]) - if arr: - partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key','=',arr[0]),('is_affiliate','=',True)]) - for s in sale_order_id.order_line: - if len(arr)>0 and partner_id: - product_tmpl_id = s.product_id.product_tmpl_id.id - aff_visit = visit.sudo().create({ - 'affiliate_method':'pps', - 'affiliate_key':arr[0], - 'affiliate_partner_id':partner_id.id, - 'url':"", - 'ip_address':request.httprequest.environ['REMOTE_ADDR'], - 'type_id':product_tmpl_id, - 'affiliate_type': 'product', - 'type_name':s.product_id.id, - 'sales_order_line_id':s.id, - 'convert_date':fields.datetime.now(), - 'affiliate_program_id': partner_id.affiliate_program_id.id, - 'product_quantity' : s.product_uom_qty, - 'is_converted':True - }) - # delete cookie after first sale occur - cookie_del_status=False - for k,v in cookies.items(): + def update_affiliate_visit_cookies(self, sale_order_id, result): + """update affiliate.visit from cokkies data i.e created in product and shop method""" + cookies = dict(request.httprequest.cookies) + visit = request.env['affiliate.visit'] + arr = [] # contains cookies product_id + for k, v in cookies.items(): if 'affkey_' in k: - cookie_del_status = result.delete_cookie(key=k) - return result - + arr.append(k.split('_')[1]) + if arr: + partner_id = request.env['res.partner'].sudo().search([('res_affiliate_key', '=', arr[0]), ('is_affiliate', '=', True)]) + for s in sale_order_id.order_line: + if len(arr) > 0 and partner_id: + product_tmpl_id = s.product_id.product_tmpl_id.id + aff_visit = visit.sudo().create({ + 'affiliate_method': 'pps', + 'affiliate_key': arr[0], + 'affiliate_partner_id': partner_id.id, + 'url': "", + 'ip_address': request.httprequest.environ['REMOTE_ADDR'], + 'type_id': product_tmpl_id, + 'affiliate_type': 'product', + 'type_name': s.product_id.id, + 'sales_order_line_id': s.id, + 'convert_date': fields.datetime.now(), + 'affiliate_program_id': partner_id.affiliate_program_id.id, + 'product_quantity': s.product_uom_qty, + 'is_converted': True + }) + # delete cookie after first sale occur + cookie_del_status = False + for k, v in cookies.items(): + if 'affkey_' in k: + cookie_del_status = result.delete_cookie(key=k) + return result def calc_cookie_expire_date(self): - ConfigValues = request.env['res.config.settings'].sudo().website_constant() - cookie_expire = ConfigValues.get('cookie_expire') - cookie_expire_period = ConfigValues.get('cookie_expire_period') - time_dict = { - 'hours':cookie_expire, - 'days':cookie_expire*24, - 'months':cookie_expire*24*30, - } - return datetime.datetime.utcnow() + datetime.timedelta(hours=time_dict[cookie_expire_period]) + ConfigValues = request.env['res.config.settings'].sudo().website_constant() + cookie_expire = ConfigValues.get('cookie_expire') + cookie_expire_period = ConfigValues.get('cookie_expire_period') + time_dict = { + 'hours': cookie_expire, + 'days': cookie_expire * 24, + 'months': cookie_expire * 24 * 30, + } + return datetime.datetime.utcnow() + datetime.timedelta(hours=time_dict[cookie_expire_period]) diff --git a/odex25_donation/affiliate_management/data/automated_scheduler_action.xml b/odex25_donation/affiliate_management/data/automated_scheduler_action.xml index 16e9055b0..252c02da7 100644 --- a/odex25_donation/affiliate_management/data/automated_scheduler_action.xml +++ b/odex25_donation/affiliate_management/data/automated_scheduler_action.xml @@ -1,6 +1,6 @@ - + - - Automated ppc maturity Scheduler - - 1 - days - -1 - - code - model.process_ppc_maturity_scheduler_queue() - - + + Automated ppc maturity Scheduler + + 1 + days + -1 + + code + model.process_ppc_maturity_scheduler_queue() + + - - - - + - - Automated invoice Scheduler - - 1 - days - -1 - - code - model.process_scheduler_queue() - - + + Automated invoice Scheduler + + 1 + days + -1 + + code + model.process_scheduler_queue() + + Create Visits Invoice - + code - if records: - action = records.create_invoice() + if records: + action = records.create_invoice() @@ -78,4 +76,4 @@ - + \ No newline at end of file diff --git a/odex25_donation/affiliate_management/data/default_affiliate_program_data.xml b/odex25_donation/affiliate_management/data/default_affiliate_program_data.xml index 2bec4fa3b..ab626c0ca 100644 --- a/odex25_donation/affiliate_management/data/default_affiliate_program_data.xml +++ b/odex25_donation/affiliate_management/data/default_affiliate_program_data.xml @@ -1,51 +1,51 @@ - - - Default Affiliate Program - s - 10 - f - 10 - + + + Default Affiliate Program + s + 10 + f + 10 + - + - + - + - + - + - + - + - + - + - - + + \ No newline at end of file diff --git a/odex25_donation/affiliate_management/data/demo_data_view.xml b/odex25_donation/affiliate_management/data/demo_data_view.xml index a12da8212..a8af1aef0 100644 --- a/odex25_donation/affiliate_management/data/demo_data_view.xml +++ b/odex25_donation/affiliate_management/data/demo_data_view.xml @@ -1,435 +1,454 @@ - - + + - - - Banner - image1 - + + + Banner + image1 + - - - Banner - image2 - + + + Banner + image2 + - - - Banner - image3 - + + + Banner + image3 + - - - Button - image4 - + + + Button + image4 + - - - Button - image5 - + + + Button + image5 + - - - Button - image6 - + + + Button + image6 + - - - Demo1 - - - 1 - DemoCity1 - 106 - - 31 Demo city street - Demo@example.com - (+886) (02) 4162 2023 - http://www.DemoUser.com - - True - 123OxPzL - - + + + Demo1 + + + 1 + DemoCity1 + 106 + + 31 Demo city street + Demo@example.com + (+886) (02) 4162 2023 + http://www.DemoUser.com + + True + 123OxPzL + + - - Demo2 - - - 1 - DemoCity2 - 106367 - - 313 Demo2 city2 street2 - Demo2@example.com - (+886) (02) 4162 2023 - http://www.DemoUser2.com - - True - 223OxPzL - - + + Demo2 + + + 1 + DemoCity2 + 106367 + + 313 Demo2 city2 street2 + Demo2@example.com + (+886) (02) 4162 2023 + http://www.DemoUser2.com + + True + 223OxPzL + + - - Demo3 - - - 1 - DemoCity3 - 106345 - - 313 Demo3 city3 street3 - Demo3@example.com - (+886) (02) 4162 2023 - http://www.DemoUser3.com - - True - 323OxPzL - - + + Demo3 + + + 1 + DemoCity3 + 106345 + + 313 Demo3 city3 street3 + Demo3@example.com + (+886) (02) 4162 2023 + http://www.DemoUser3.com + + True + 323OxPzL + + - - Demo1@example.com - webkul - - - - - + + Demo1@example.com + webkul + + + + + - - Demo2@example.com - webkul - - - - - + + Demo2@example.com + webkul + + + + + - - Demo3@example.com - webkul - - - - - + + Demo3@example.com + webkul + + + + + - - - webkul - Demo1@example.com - - aproove - - + + + webkul + Demo1@example.com + + aproove + + - - webkul - Demo2@example.com - - aproove - - + + webkul + Demo2@example.com + + aproove + + - - webkul - Demo3@example.com - - aproove - - + + webkul + Demo3@example.com + + aproove + + - - - Demo4 - - - 1 - DemoCity4 - 106345 - - 313 Demo4 city4 street4 - Demo4@example.com - (+886) (02) 4162 2023 - http://www.DemoUser4.com - - + + Demo4 + + + 1 + DemoCity4 + 106345 + + 313 Demo4 city4 street4 + Demo4@example.com + (+886) (02) 4162 2023 + http://www.DemoUser4.com + + - - - Demo4@example.com - webkul - - - - - + + + Demo4@example.com + webkul + + + + + - - webkul - Demo4@example.com - - register - - + + webkul + Demo4@example.com + + register + + - - Demo5 - - - 1 - DemoCity5 - 106345 - - 313 Demo5 city5 street5 - Demo4@example.com - (+886) (02) 4162 2023 - http://www.DemoUser5.com - - + + 1 + DemoCity5 + 106345 + + 313 Demo5 city5 street5 + Demo4@example.com + (+886) (02) 4162 2023 + http://www.DemoUser5.com + + - + - - Demo5@example.com - webkul - - - - - - - webkul - Demo5@example.com - - register - - + + Demo5@example.com + webkul + + + + + + + webkul + Demo5@example.com + + register + + - - - Demo6@example.com - draft - CJyPAvexmav0Bar8C456 - + + + Demo6@example.com + draft + CJyPAvexmav0Bar8C456 + - - Demo7@example.com - draft - CJyPAvex1230Bar8C456 - + + Demo7@example.com + draft + CJyPAvex1230Bar8C456 + + + + - - - + + + - - - + + Zed+ Antivirus + + 1 + + + 2950.00 + - - Zed+ Antivirus - - 1 - - - 2950.00 - - - - Antivirus - - 1 - - - 950.00 - + + Antivirus + + 1 + + + 950.00 + - - ppc - product - 15 - iMac - False - 123OxPzL - - /shop/product/e-com09-imac-15?aff_key=123OxPzL - - draft - - + + ppc + product + 15 + iMac + False + 123OxPzL + + /shop/product/e-com09-imac-15?aff_key=123OxPzL + + draft + + - - ppc - product - 15 - iPad - False - 223OxPzL - - /shop/product/e-com09-ipad-10?aff_key=223OxPzL - - draft - - + + ppc + product + 15 + iPad + False + 223OxPzL + + /shop/product/e-com09-ipad-10?aff_key=223OxPzL + + draft + + - - pps - product - 6 - Zed+ Antivirus - True - - 123OxPzL - - /shop/product/prod-order-zed-antivirus-6?aff_key=123OxPzL - - draft - 1 - + + pps + product + 6 + Zed+ Antivirus + True + + 123OxPzL + + /shop/product/prod-order-zed-antivirus-6?aff_key=123OxPzL + + draft + 1 + - - pps - product - 6 - Antivirus - True - - 223OxPzL - - /shop/product/prod-antivirus-6?aff_key=223OxPzL - - draft - 1 - + + pps + product + 6 + Antivirus + True + + 223OxPzL + + /shop/product/prod-antivirus-6?aff_key=223OxPzL + + draft + 1 + - - ppc - product - 20 - Bosh Speaker - False - 323OxPzL - - /shop/product/e-com09-ipad-20?aff_key=323OxPzL - - draft - + + ppc + product + 20 + Bosh Speaker + False + 323OxPzL + + /shop/product/e-com09-ipad-20?aff_key=323OxPzL + + draft + - - ppc - product - 25 - Xemberg Shoes - False - 323OxPzL - - /shop/product/e-com09-ipad-40?aff_key=323OxPzL - - draft - + + ppc + product + 25 + Xemberg Shoes + False + 323OxPzL + + /shop/product/e-com09-ipad-40?aff_key=323OxPzL + + draft + - - Advance Commission - True - + + Advance Commission + True + - - product - - 1_product - 10 - fixed - 10 - 1 - + + product + + 1_product + 10 + fixed + 10 + 1 + - - product - - 2_product_category - 4 - fixed - 10 - 1 - + + product + + 2_product_category + 4 + fixed + 10 + 1 + - - product - - 3_global - fixed - 10 - 1 - + + product + + 3_global + fixed + 10 + 1 + + + Advance Commission2 + True + - - Advance Commission2 - True - + + product + + 1_product + 20 + fixed + 100 + 1 + + + + product + + 2_product_category + 9 + fixed + 100 + 1 + + + + product + + 3_global + fixed + 100 + 1 + - - product - - 1_product - 20 - fixed - 100 - 1 - - - - product - - 2_product_category - 9 - fixed - 100 - 1 - - - - product - - 3_global - fixed - 100 - 1 - - - - - + - +If the visitor orders, the order will be registered as a sale for you and you will receive a +commission for this sale. --> \ No newline at end of file diff --git a/odex25_donation/affiliate_management/data/sequence_view.xml b/odex25_donation/affiliate_management/data/sequence_view.xml index ce78a86cf..85641bc83 100644 --- a/odex25_donation/affiliate_management/data/sequence_view.xml +++ b/odex25_donation/affiliate_management/data/sequence_view.xml @@ -1,12 +1,12 @@ - - - Program No - affiliate.visit - VST - 6 - - + + + Program No + affiliate.visit + VST + 6 + + - - + + \ No newline at end of file diff --git a/odex25_donation/affiliate_management/help.txt b/odex25_donation/affiliate_management/help.txt deleted file mode 100644 index 213eaad06..000000000 --- a/odex25_donation/affiliate_management/help.txt +++ /dev/null @@ -1,5 +0,0 @@ -affiliate_ir_property_manager,manager_access_ir_property,base.model_ir_property,affiliate_security_manager_group,1,1,1,1 -affiliate_res_company_manager,manager_access_res_company,base.model_res_company,affiliate_security_manager_group,1,1,0,0 -affiliate_ir_module_module_manager,manager_access_ir_module_module,base.model_ir_module_module,affiliate_security_manager_group,1,1,0,0 -affiliate_ir_config_parameter_manager,manager_access_ir_config_parameter,base.model_ir_config_parameter,affiliate_security_manager_group,1,1,0,0 -affiliate_ir_rule_manager,manager_access_ir_rule,base.model_ir_rule,affiliate_security_manager_group,1,1,0,0 diff --git a/odex25_donation/affiliate_management/models/__init__.py b/odex25_donation/affiliate_management/models/__init__.py index b90e2d91e..83d519e17 100644 --- a/odex25_donation/affiliate_management/models/__init__.py +++ b/odex25_donation/affiliate_management/models/__init__.py @@ -21,7 +21,7 @@ from . import affiliate_config_setting from . import account_invoice_inherit from . import affiliate_tool from . import affiliate_banner -from . import affiliate_request +from . import affiliate_request from . import affiliate_image from . import advance_commision from . import affiliate_product_pricelist_item diff --git a/odex25_donation/affiliate_management/models/account_invoice_inherit.py b/odex25_donation/affiliate_management/models/account_invoice_inherit.py index 59beb781c..f29e09e87 100644 --- a/odex25_donation/affiliate_management/models/account_invoice_inherit.py +++ b/odex25_donation/affiliate_management/models/account_invoice_inherit.py @@ -13,19 +13,19 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +import string +import random +from odoo.http import request +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ -import random, string -from odoo.http import request class AccountInvoiceInherit(models.Model): _inherit = 'account.move' - - aff_visit_id = fields.One2many('affiliate.visit','act_invoice_id',string="Report") + aff_visit_id = fields.One2many('affiliate.visit', 'act_invoice_id', string="Report") # def write(self, vals): @@ -40,21 +40,18 @@ class AccountInvoiceInherit(models.Model): # return result - - class AccountPaymentInherit(models.Model): _inherit = 'account.payment' _description = "Account Payment Inherit Model" - # def action_validate_invoice_payment(self): def action_post(self): - result = super(AccountPaymentInherit,self).action_post() + result = super(AccountPaymentInherit, self).action_post() active_id = self._context.get('active_id') move_id = self.env['account.move'].browse([active_id]) if move_id: if move_id.state == "posted" and move_id.aff_visit_id: for visit in move_id.aff_visit_id: if visit.state != "paid": - visit.write({"state":"paid"}) + visit.write({"state": "paid"}) return result diff --git a/odex25_donation/affiliate_management/models/advance_commision.py b/odex25_donation/affiliate_management/models/advance_commision.py index 3db8ae9d5..a67cc4cd8 100644 --- a/odex25_donation/affiliate_management/models/advance_commision.py +++ b/odex25_donation/affiliate_management/models/advance_commision.py @@ -13,18 +13,17 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ class AffiliateCommision(models.Model): _name = "advance.commision" _description = "Affiliate Commision Model" name = fields.Char(string="Name", required=True) - pricelist_item_ids = fields.One2many("affiliate.product.pricelist.item",'advance_commision_id',string="Item") - active_adv_comsn = fields.Boolean(default=True,string="Active") - + pricelist_item_ids = fields.One2many("affiliate.product.pricelist.item", 'advance_commision_id', string="Item") + active_adv_comsn = fields.Boolean(default=True, string="Active") def toggle_active_button(self): if self.active_adv_comsn: @@ -33,20 +32,20 @@ class AffiliateCommision(models.Model): self.active_adv_comsn = True # argument of calc_commision_adv(adv_comm_id, product_id on which commision apply , price of product) - def calc_commision_adv(self, adv_comsn_id, product_templ_id , product_price): + def calc_commision_adv(self, adv_comsn_id, product_templ_id, product_price): _logger.info("-----in adcvace commision model-- method-- calc_commision_adv-----") product_tmpl_category_ids = self.env['product.template'].browse([product_templ_id]).public_categ_ids - _logger.info("**********-----product_tmpl_category_ids--%r********",product_tmpl_category_ids) + _logger.info("**********-----product_tmpl_category_ids--%r********", product_tmpl_category_ids) - pricelist_ids = self.env['affiliate.product.pricelist.item'].search([('advance_commision_id','=',adv_comsn_id)]) + pricelist_ids = self.env['affiliate.product.pricelist.item'].search([('advance_commision_id', '=', adv_comsn_id)]) for pricelist_id in pricelist_ids: - _logger.info("***====pricelist_id.name=%r======",pricelist_id.name) + _logger.info("***====pricelist_id.name=%r======", pricelist_id.name) commision_value = False commision_value_type = False adv_commision_amount = False - # on global product + # on global product if pricelist_id.applied_on == "3_global": if pricelist_id.compute_price == "fixed": commision_value = pricelist_id.fixed_price @@ -54,7 +53,7 @@ class AffiliateCommision(models.Model): adv_commision_amount = pricelist_id.fixed_price else: if pricelist_id.compute_price == "percentage": - commision_value = product_price * (pricelist_id.percent_price /100) + commision_value = product_price * (pricelist_id.percent_price / 100) commision_value_type = 'percentage' adv_commision_amount = pricelist_id.percent_price @@ -69,13 +68,12 @@ class AffiliateCommision(models.Model): else: if pricelist_id.compute_price == "percentage": - commision_value = product_price * (pricelist_id.percent_price /100) + commision_value = product_price * (pricelist_id.percent_price / 100) commision_value_type = 'percentage' adv_commision_amount = pricelist_id.percent_price - else: - # on specific product + # on specific product if pricelist_id.applied_on == "1_product": if product_templ_id == pricelist_id.product_tmpl_id.id: if pricelist_id.compute_price == "fixed": @@ -85,16 +83,13 @@ class AffiliateCommision(models.Model): else: if pricelist_id.compute_price == "percentage": - commision_value = product_price * (pricelist_id.percent_price /100) + commision_value = product_price * (pricelist_id.percent_price / 100) commision_value_type = 'percentage' adv_commision_amount = pricelist_id.percent_price - if commision_value and commision_value_type: break # this break is used for if advance commission found in pricelist ids # then it will break so that further pricelist ids is not executed in for loop # this is for calculation advance commission base on global, perticular product or category - return adv_commision_amount,commision_value , commision_value_type - - \ No newline at end of file + return adv_commision_amount, commision_value, commision_value_type diff --git a/odex25_donation/affiliate_management/models/affiliate_banner.py b/odex25_donation/affiliate_management/models/affiliate_banner.py index c4c6c0c8e..ae273afab 100644 --- a/odex25_donation/affiliate_management/models/affiliate_banner.py +++ b/odex25_donation/affiliate_management/models/affiliate_banner.py @@ -13,10 +13,10 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ class AffiliateBanner(models.Model): _name = "affiliate.banner" _description = "Affiliate Banner Model" @@ -24,12 +24,11 @@ class AffiliateBanner(models.Model): banner_title = fields.Text(string="Banner Text") banner_image = fields.Binary(string="Banner Image") - @api.model_create_multi - def create(self,vals_list): + def create(self, vals_list): res = None for vals in vals_list: if vals.get('banner_image') == False: raise UserError("Image field is mandatory") - res = super(AffiliateBanner,self).create(vals) + res = super(AffiliateBanner, self).create(vals) return res diff --git a/odex25_donation/affiliate_management/models/affiliate_config_setting.py b/odex25_donation/affiliate_management/models/affiliate_config_setting.py index f76bc5397..b45af5458 100644 --- a/odex25_donation/affiliate_management/models/affiliate_config_setting.py +++ b/odex25_donation/affiliate_management/models/affiliate_config_setting.py @@ -13,10 +13,10 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo.exceptions import UserError +from odoo import api, fields, models, _ import logging _logger = logging.getLogger(__name__) -from odoo import api, fields, models, _ -from odoo.exceptions import UserError class AffiliateConfiguration(models.TransientModel): @@ -27,7 +27,7 @@ class AffiliateConfiguration(models.TransientModel): def _get_program(self): # _logger.info("-----_get_program-----%r-----",self.env['affiliate.program'].search([])) # self.remove_prgm() - return self.env['affiliate.program'].search([],limit=1).id + return self.env['affiliate.program'].search([], limit=1).id def remove_prgm(self): # _logger.info("----remove_prgm--env['affiliate.program']------%r-----",self.env['affiliate.program'].search([])) @@ -35,36 +35,33 @@ class AffiliateConfiguration(models.TransientModel): for p in prgm: p.unlink() - @api.model def _get_banner(self): - return self.env['affiliate.banner'].search([],limit=1).id + return self.env['affiliate.banner'].search([], limit=1).id - affiliate_program_id = fields.Many2one('affiliate.program',string=" Affiliate Program") - enable_ppc = fields.Boolean(string= "Enable PPC", default=True ) - auto_approve_request = fields.Boolean(default=False ) - ppc_maturity = fields.Integer(string="PPC Maturity",required=True, default=1) - ppc_maturity_period = fields.Selection([('days','Days'),('months','Months'),('weeks','Weeks')],required=True,default='days') - cookie_expire = fields.Integer(string="Cookie expiration",required=True, default=1) - cookie_expire_period = fields.Selection([('hours','Hours'),('days','Days'),('months','Months')],required=True,default='days') - payment_day = fields.Integer(string="Payment day",required=True, default=7) - minimum_amt = fields.Integer(string="Minimum Payout Balance",required=True, default=0) + affiliate_program_id = fields.Many2one('affiliate.program', string=" Affiliate Program") + enable_ppc = fields.Boolean(string="Enable PPC", default=True) + auto_approve_request = fields.Boolean(default=False) + ppc_maturity = fields.Integer(string="PPC Maturity", required=True, default=1) + ppc_maturity_period = fields.Selection([('days', 'Days'), ('months', 'Months'), ('weeks', 'Weeks')], required=True, default='days') + cookie_expire = fields.Integer(string="Cookie expiration", required=True, default=1) + cookie_expire_period = fields.Selection([('hours', 'Hours'), ('days', 'Days'), ('months', 'Months')], required=True, default='days') + payment_day = fields.Integer(string="Payment day", required=True, default=7) + minimum_amt = fields.Integer(string="Minimum Payout Balance", required=True, default=0) currency_id = fields.Many2one('res.currency', 'Currency', required=True, - default=lambda self: self.env.user.company_id.currency_id.id) - aff_product_id = fields.Many2one('product.product', 'Product',help="Product used in Invoicing") - enable_signup = fields.Boolean(string= "Enable Sign Up", default=True ) - enable_login = fields.Boolean(string= "Enable Log In", default=True ) - enable_forget_pwd = fields.Boolean(string= "Enable Forget Password", default=False ) - affiliate_banner_id = fields.Many2one('affiliate.banner',string="Bannner") - welcome_mail_template = fields.Many2one('mail.template',string="Approved Request Mail",readonly=True ) - reject_mail_template = fields.Many2one('mail.template',string="Reject Request Mail ",readonly=True) - Invitation_mail_template = fields.Many2one('mail.template',string="Invitation Request Mail ",readonly=True) - unique_ppc_traffic = fields.Boolean(string= "Unique ppc for product", default=False,help="this field is used to enable unique traffic on product for an Affiliate for a specific browser. " ) - term_condition = fields.Html(string="Term & condition Text", related='affiliate_program_id.term_condition',translate=True) - work_title = fields.Text(string="How Does It Work Title",related='affiliate_program_id.work_title', translate=True) - work_text = fields.Html(string="How Does It Work Text",related='affiliate_program_id.work_text', translate=True) - - + default=lambda self: self.env.user.company_id.currency_id.id) + aff_product_id = fields.Many2one('product.product', 'Product', help="Product used in Invoicing") + enable_signup = fields.Boolean(string="Enable Sign Up", default=True) + enable_login = fields.Boolean(string="Enable Log In", default=True) + enable_forget_pwd = fields.Boolean(string="Enable Forget Password", default=False) + affiliate_banner_id = fields.Many2one('affiliate.banner', string="Bannner") + welcome_mail_template = fields.Many2one('mail.template', string="Approved Request Mail", readonly=True) + reject_mail_template = fields.Many2one('mail.template', string="Reject Request Mail ", readonly=True) + Invitation_mail_template = fields.Many2one('mail.template', string="Invitation Request Mail ", readonly=True) + unique_ppc_traffic = fields.Boolean(string="Unique ppc for product", default=False, help="this field is used to enable unique traffic on product for an Affiliate for a specific browser. ") + term_condition = fields.Html(string="Term & condition Text", related='affiliate_program_id.term_condition', translate=True) + work_title = fields.Text(string="How Does It Work Title", related='affiliate_program_id.work_title', translate=True) + work_text = fields.Html(string="How Does It Work Text", related='affiliate_program_id.work_text', translate=True) # @api.multi def set_values(self): @@ -75,11 +72,11 @@ class AffiliateConfiguration(models.TransientModel): IrDefault.set('res.config.settings', 'ppc_maturity', self.ppc_maturity) IrDefault.set('res.config.settings', 'ppc_maturity_period', self.ppc_maturity_period) IrDefault.set('res.config.settings', 'enable_ppc', self.enable_ppc) - IrDefault.set('res.config.settings', 'auto_approve_request', self.auto_approve_request ) + IrDefault.set('res.config.settings', 'auto_approve_request', self.auto_approve_request) IrDefault.set('res.config.settings', 'aff_product_id', self.aff_product_id.id) - IrDefault.set('res.config.settings', 'enable_signup', self.enable_signup ) - IrDefault.set('res.config.settings', 'enable_login', self.enable_login ) - IrDefault.set('res.config.settings', 'enable_forget_pwd', self.enable_forget_pwd ) + IrDefault.set('res.config.settings', 'enable_signup', self.enable_signup) + IrDefault.set('res.config.settings', 'enable_login', self.enable_login) + IrDefault.set('res.config.settings', 'enable_forget_pwd', self.enable_forget_pwd) IrDefault.set('res.config.settings', 'payment_day', self.payment_day) IrDefault.set('res.config.settings', 'minimum_amt', self.minimum_amt) IrDefault.set('res.config.settings', 'cookie_expire', self.cookie_expire) @@ -90,7 +87,6 @@ class AffiliateConfiguration(models.TransientModel): IrDefault.set('res.config.settings', 'work_title', self.work_title) IrDefault.set('res.config.settings', 'work_text', self.work_text) - # IrDefault.set('res.config.settings', 'affiliate_program_id', self.affiliate_program_id.id) # IrDefault.set('res.config.settings', 'affiliate_banner_id', self.affiliate_banner_id.id) IrDefault.set('res.config.settings', 'affiliate_program_id', self._get_program()) @@ -100,66 +96,65 @@ class AffiliateConfiguration(models.TransientModel): def scheduler_ppc_maturity_set(self): ppc_maturity_schedular = self.env.ref("affiliate_management.affiliate_ppc_maturity_scheduler_call") ppc_maturity_schedular.write({ - 'interval_number' : self.ppc_maturity, - 'interval_type' : self.ppc_maturity_period, + 'interval_number': self.ppc_maturity, + 'interval_type': self.ppc_maturity_period, }) - @api.model def get_values(self): - template_1 = self.env['ir.model.data']._xmlid_lookup('affiliate_management.welcome_affiliate_email')[2] - template_2 = self.env['ir.model.data']._xmlid_lookup('affiliate_management.reject_affiliate_email')[2] - template_3 = self.env['ir.model.data']._xmlid_lookup('affiliate_management.join_affiliate_email')[2] + template_1 = self.env.ref('affiliate_management.welcome_affiliate_email', raise_if_not_found=False).id + template_2 = self.env.ref('affiliate_management.reject_affiliate_email', raise_if_not_found=False).id + template_3 = self.env.ref('affiliate_management.join_affiliate_email', raise_if_not_found=False).id res = super(AffiliateConfiguration, self).get_values() IrDefault = self.env['ir.default'].sudo() res.update( welcome_mail_template=IrDefault.get('res.config.settings', 'welcome_mail_template') or template_1, reject_mail_template=IrDefault.get('res.config.settings', 'reject_mail_template') or template_2, Invitation_mail_template=IrDefault.get('res.config.settings', 'Invitation_mail_template') or template_3, - work_title=IrDefault.get('res.config.settings', 'work_title') or _("The process is very simple. Simply, signup/login to your affiliate portal, pick your affiliate link and place them into your website/blogs and watch your account balance grow as your visitors become our customers, as :"), + work_title=IrDefault.get('res.config.settings', 'work_title') or _( + "The process is very simple. Simply, signup/login to your affiliate portal, pick your affiliate link and place them into your website/blogs and watch your account balance grow as your visitors become our customers, as :"), work_text=IrDefault.get('res.config.settings', 'work_text') or _("
  1. Visitor clicks on affiliate links posted on your website/blogs.

  2. A cookie is placed in their browser for tracking purposes. The visitor browses our site and may decide to order.

  3. The visitor browses our site and may decide to order. If the visitor orders, the order will be registered as a sale for you and you will receive a commission for this sale.

  4. If the visitor orders, the order will be registered as a sale for you and you will receive a commission for this sale.

"), unique_ppc_traffic=IrDefault.get('res.config.settings', 'unique_ppc_traffic') or False, term_condition=IrDefault.get('res.config.settings', 'term_condition') or _("Write your own Term and Condition"), - ppc_maturity =IrDefault.get('res.config.settings', 'ppc_maturity') or 1, - ppc_maturity_period=IrDefault.get('res.config.settings', 'ppc_maturity_period')or 'months', - enable_ppc =IrDefault.get('res.config.settings', 'enable_ppc') or False, - auto_approve_request =IrDefault.get('res.config.settings', 'auto_approve_request' ) or False, + ppc_maturity=IrDefault.get('res.config.settings', 'ppc_maturity') or 1, + ppc_maturity_period=IrDefault.get('res.config.settings', 'ppc_maturity_period') or 'months', + enable_ppc=IrDefault.get('res.config.settings', 'enable_ppc') or False, + auto_approve_request=IrDefault.get('res.config.settings', 'auto_approve_request') or False, aff_product_id=IrDefault.get('res.config.settings', 'aff_product_id') or False, - enable_signup =IrDefault.get('res.config.settings', 'enable_signup') or False, - enable_login =IrDefault.get('res.config.settings', 'enable_login' ) or False, - enable_forget_pwd =IrDefault.get('res.config.settings', 'enable_forget_pwd') or False, - payment_day =IrDefault.get('res.config.settings', 'payment_day') or 7, - minimum_amt =IrDefault.get('res.config.settings', 'minimum_amt') or 1, + enable_signup=IrDefault.get('res.config.settings', 'enable_signup') or False, + enable_login=IrDefault.get('res.config.settings', 'enable_login') or False, + enable_forget_pwd=IrDefault.get('res.config.settings', 'enable_forget_pwd') or False, + payment_day=IrDefault.get('res.config.settings', 'payment_day') or 7, + minimum_amt=IrDefault.get('res.config.settings', 'minimum_amt') or 1, cookie_expire=IrDefault.get('res.config.settings', 'cookie_expire') or 1, - cookie_expire_period =IrDefault.get('res.config.settings', 'cookie_expire_period') or 'days', - affiliate_program_id =IrDefault.get('res.config.settings', 'affiliate_program_id') or self._get_program(), - affiliate_banner_id =IrDefault.get('res.config.settings', 'affiliate_banner_id') or self._get_banner(), - ) + cookie_expire_period=IrDefault.get('res.config.settings', 'cookie_expire_period') or 'days', + affiliate_program_id=IrDefault.get('res.config.settings', 'affiliate_program_id') or self._get_program(), + affiliate_banner_id=IrDefault.get('res.config.settings', 'affiliate_banner_id') or self._get_banner(), + ) return res def website_constant(self): - res ={} + res = {} IrDefault = self.env['ir.default'].sudo() aff_prgmObj = self.env['affiliate.program'].search([], limit=1) res.update( - work_title = aff_prgmObj.work_title or "The process is very simple. Simply, signup/login to your affiliate portal, pick your affiliate link and place them into your website/blogs and watch your account balance grow as your visitors become our customers, as :", - work_text = aff_prgmObj.work_text or "
  1. Visitor clicks on affiliate links posted on your website/blogs.

  2. A cookie is placed in their browser for tracking purposes.

  3. The visitor browses our site and may decide to order.

  4. If the visitor orders, the order will be registered as a sale for you and you will receive a commission for this sale.

", - unique_ppc_traffic = IrDefault.get('res.config.settings', 'unique_ppc_traffic') or False, - term_condition = aff_prgmObj.term_condition or "Write your own Term and Condition", - enable_ppc =IrDefault.get('res.config.settings', 'enable_ppc') or False, - enable_signup =IrDefault.get('res.config.settings', 'enable_signup') or False, - enable_login =IrDefault.get('res.config.settings', 'enable_login' ) or False, - enable_forget_pwd =IrDefault.get('res.config.settings', 'enable_forget_pwd') or False, - auto_approve_request =IrDefault.get('res.config.settings', 'auto_approve_request' ) or False, + work_title=aff_prgmObj.work_title or "The process is very simple. Simply, signup/login to your affiliate portal, pick your affiliate link and place them into your website/blogs and watch your account balance grow as your visitors become our customers, as :", + work_text=aff_prgmObj.work_text or "
  1. Visitor clicks on affiliate links posted on your website/blogs.

  2. A cookie is placed in their browser for tracking purposes.

  3. The visitor browses our site and may decide to order.

  4. If the visitor orders, the order will be registered as a sale for you and you will receive a commission for this sale.

", + unique_ppc_traffic=IrDefault.get('res.config.settings', 'unique_ppc_traffic') or False, + term_condition=aff_prgmObj.term_condition or "Write your own Term and Condition", + enable_ppc=IrDefault.get('res.config.settings', 'enable_ppc') or False, + enable_signup=IrDefault.get('res.config.settings', 'enable_signup') or False, + enable_login=IrDefault.get('res.config.settings', 'enable_login') or False, + enable_forget_pwd=IrDefault.get('res.config.settings', 'enable_forget_pwd') or False, + auto_approve_request=IrDefault.get('res.config.settings', 'auto_approve_request') or False, cookie_expire=IrDefault.get('res.config.settings', 'cookie_expire') or 1, - cookie_expire_period =IrDefault.get('res.config.settings', 'cookie_expire_period') or 'days', - payment_day =IrDefault.get('res.config.settings', 'payment_day') or 7, - minimum_amt =IrDefault.get('res.config.settings', 'minimum_amt') or 1, + cookie_expire_period=IrDefault.get('res.config.settings', 'cookie_expire_period') or 'days', + payment_day=IrDefault.get('res.config.settings', 'payment_day') or 7, + minimum_amt=IrDefault.get('res.config.settings', 'minimum_amt') or 1, aff_product_id=IrDefault.get('res.config.settings', 'aff_product_id') or False, - ) + ) return res - # @api.multi def open_program(self): return { diff --git a/odex25_donation/affiliate_management/models/affiliate_image.py b/odex25_donation/affiliate_management/models/affiliate_image.py index b23bd9e76..4570a2789 100644 --- a/odex25_donation/affiliate_management/models/affiliate_image.py +++ b/odex25_donation/affiliate_management/models/affiliate_image.py @@ -13,24 +13,22 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ class AffiliateImage(models.Model): _name = "affiliate.image" _description = "Affiliate Image Model" _inherit = ['mail.thread'] - - name = fields.Char(string = "Name",required=True) - title = fields.Char(string = "Title",required=True) - banner_height = fields.Integer(string = "Height") - bannner_width = fields.Integer(string = "Width") - image = fields.Binary(string="Image",required=True) + name = fields.Char(string="Name", required=True) + title = fields.Char(string="Title", required=True) + banner_height = fields.Integer(string="Height") + bannner_width = fields.Integer(string="Width") + image = fields.Binary(string="Image", required=True) user_id = fields.Many2one('res.users', string='current user', index=True, tracking=True, default=lambda self: self.env.user) - image_active = fields.Boolean(string="Active",default=True) - + image_active = fields.Boolean(string="Active", default=True) def toggle_active_button(self): if self.image_active: @@ -38,12 +36,11 @@ class AffiliateImage(models.Model): else: self.image_active = True - @api.model_create_multi - def create(self,vals_list): + def create(self, vals_list): res = None for vals in vals_list: if vals.get('image') == False: raise UserError("Image field is mandatory") - res = super(AffiliateImage,self).create(vals) + res = super(AffiliateImage, self).create(vals) return res diff --git a/odex25_donation/affiliate_management/models/affiliate_product_pricelist_item.py b/odex25_donation/affiliate_management/models/affiliate_product_pricelist_item.py index 8f6605cb8..fb7689558 100644 --- a/odex25_donation/affiliate_management/models/affiliate_product_pricelist_item.py +++ b/odex25_donation/affiliate_management/models/affiliate_product_pricelist_item.py @@ -13,10 +13,10 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ class AffiliateProductPricelistItem(models.Model): _name = "affiliate.product.pricelist.item" @@ -44,9 +44,9 @@ class AffiliateProductPricelistItem(models.Model): percent_price = fields.Float('Percentage Price') currency_id = fields.Many2one('res.currency', 'Currency', required=True, - default=lambda self: self.env.user.company_id.currency_id.id,readonly='True') + default=lambda self: self.env.user.company_id.currency_id.id, readonly='True') sequence = fields.Integer(required=True, default=1, - help="The sequence field is used to define order in which the pricelist item are applied.") + help="The sequence field is used to define order in which the pricelist item are applied.") # @api.multi def write(self, vals): @@ -67,7 +67,7 @@ class AffiliateProductPricelistItem(models.Model): if change_value <= 0: raise UserError("Price List Item value must be greater than zero.") - return super(AffiliateProductPricelistItem,self).write(vals) + return super(AffiliateProductPricelistItem, self).write(vals) @api.model_create_multi def create(self, vals_list): @@ -76,10 +76,10 @@ class AffiliateProductPricelistItem(models.Model): if (vals.get('compute_price') == 'fixed') and vals.get('fixed_price') <= 0: raise UserError("Price List Item value must be greater than zero.") - if (vals.get('compute_price') == 'percentage') and vals.get('percent_price') <= 0: + if (vals.get('compute_price') == 'percentage') and vals.get('percent_price') <= 0: raise UserError("Price List Item value must be greater than zero.") - - res = super(AffiliateProductPricelistItem,self).create(vals) + + res = super(AffiliateProductPricelistItem, self).create(vals) return res diff --git a/odex25_donation/affiliate_management/models/affiliate_program.py b/odex25_donation/affiliate_management/models/affiliate_program.py index 010063f0b..ecddc02d0 100644 --- a/odex25_donation/affiliate_management/models/affiliate_program.py +++ b/odex25_donation/affiliate_management/models/affiliate_program.py @@ -14,30 +14,29 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ class AffiliateProgram(models.Model): _name = "affiliate.program" _description = "Affiliate Model" - name = fields.Char(string = "Name",required=True) - ppc_type = fields.Selection([("s","Simple"),("a","Advance")], string="Ppc Type",required=True,default="s") - amount_ppc_fixed = fields.Float(string="Amount Fixed",default=0,required=True) - pps_type = fields.Selection([("s","Simple"),("a","Advanced")], string="Pps Type",required=True,default="s") - matrix_type = fields.Selection([("f","Fixed"),("p","Percentage")],required=True,default='f',string="Matrix Type") - amount = fields.Float(string="Amount",default=0, required=True) + name = fields.Char(string="Name", required=True) + ppc_type = fields.Selection([("s", "Simple"), ("a", "Advance")], string="Ppc Type", required=True, default="s") + amount_ppc_fixed = fields.Float(string="Amount Fixed", default=0, required=True) + pps_type = fields.Selection([("s", "Simple"), ("a", "Advanced")], string="Pps Type", required=True, default="s") + matrix_type = fields.Selection([("f", "Fixed"), ("p", "Percentage")], required=True, default='f', string="Matrix Type") + amount = fields.Float(string="Amount", default=0, required=True) currency_id = fields.Many2one('res.currency', 'Currency', - default=lambda self: self.env.user.company_id.currency_id.id) - advance_commision_id = fields.Many2one('advance.commision',string="Pricelist",domain="[('active_adv_comsn', '=', True)]") + default=lambda self: self.env.user.company_id.currency_id.id) + advance_commision_id = fields.Many2one('advance.commision', string="Pricelist", domain="[('active_adv_comsn', '=', True)]") # config field for translation term_condition = fields.Html(string="Term & condition Text", translate=True) work_title = fields.Text(string="How Does It Work Title", translate=True) work_text = fields.Html(string="How Does It Work Text", translate=True) - def unlink(self): raise UserError(_("You can't delete the Affiliate Program.")) @@ -57,8 +56,8 @@ class AffiliateProgram(models.Model): self.amount = 0 def write(self, vals): - if vals.get('work_text') and vals.get('work_text')=='


': + if vals.get('work_text') and vals.get('work_text') == '


': vals['work_text'] = None - if vals.get('term_condition') and vals.get('term_condition')=='


': + if vals.get('term_condition') and vals.get('term_condition') == '


': vals['term_condition'] = None return super(AffiliateProgram, self).write(vals) diff --git a/odex25_donation/affiliate_management/models/affiliate_request.py b/odex25_donation/affiliate_management/models/affiliate_request.py index f507cfbaa..6229d31e6 100644 --- a/odex25_donation/affiliate_management/models/affiliate_request.py +++ b/odex25_donation/affiliate_management/models/affiliate_request.py @@ -13,16 +13,16 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +from odoo.http import request +from odoo import SUPERUSER_ID +from ast import literal_eval +import random +from odoo.addons.auth_signup.models.res_partner import SignupError, now +from datetime import datetime, timedelta +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ -from datetime import datetime, timedelta -from odoo.addons.auth_signup.models.res_partner import SignupError, now -import random -from ast import literal_eval -from odoo import SUPERUSER_ID -from odoo.http import request class AffiliateRequest(models.Model): @@ -31,19 +31,16 @@ class AffiliateRequest(models.Model): # _inherit = ['ir.needaction_mixin'] def random_token(self): - # the token has an entropy of about 120 bits (6 bits/char * 20 chars) + # the token has an entropy of about 120 bits (6 bits/char * 20 chars) chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' return ''.join(random.SystemRandom().choice(chars) for i in range(20)) - - - - password = fields.Char(string='password',invisible=True) + password = fields.Char(string='password', invisible=True) name = fields.Char(string="Email") partner_id = fields.Many2one('res.partner') - signup_token = fields.Char(string='Token',invisible=True) + signup_token = fields.Char(string='Token', invisible=True) signup_expiration = fields.Datetime(copy=False) - signup_valid = fields.Boolean(compute='_compute_signup_valid', string='Signup Token is Valid',default=False) + signup_valid = fields.Boolean(compute='_compute_signup_valid', string='Signup Token is Valid', default=False) signup_type = fields.Char(string='Signup Token Type', copy=False) # user_id = fields.Integer(string='User',help='check wether the request have user id') user_id = fields.Many2one('res.users') @@ -54,24 +51,23 @@ class AffiliateRequest(models.Model): ('register', 'Pending For Approval'), ('cancel', 'Rejected'), ('aproove', 'Approved'), - ], string='Status', readonly=True, default='draft' ) - + ], string='Status', readonly=True, default='draft') @api.model_create_multi def create(self, vals_list): aff_request = None for vals in vals_list: - _logger.info("these are vals we need to create aff req %r",vals) + _logger.info("these are vals we need to create aff req %r", vals) if vals.get('user_id'): # for portal user - if len(self.search([('user_id','=',vals.get('user_id'))])) == 0: - aff_request = super(AffiliateRequest,self).create(vals) + if len(self.search([('user_id', '=', vals.get('user_id'))])) == 0: + aff_request = super(AffiliateRequest, self).create(vals) else: - aff_request = self.search([('user_id','=',vals.get('user_id'))]) + aff_request = self.search([('user_id', '=', vals.get('user_id'))]) else: # for new user signup with affilaite sign up page - aff_request = super(AffiliateRequest,self).create(vals) + aff_request = super(AffiliateRequest, self).create(vals) aff_request.signup_token = self.random_token() aff_request.signup_expiration = fields.Datetime.now() aff_request.signup_type = 'signup' @@ -81,22 +77,20 @@ class AffiliateRequest(models.Model): # @api.multi def _compute_signup_valid(self): - """after one day sign up token is valid false""" if self.user_id: self.signup_valid = self.signup_valid pass else: dt = fields.Datetime.from_string(fields.Datetime.now()) - expiration = fields.Datetime.from_string(self.signup_expiration)+timedelta(days=1) + expiration = fields.Datetime.from_string(self.signup_expiration) + timedelta(days=1) if dt > expiration: self.signup_valid = False else: self.signup_valid = True - def action_cancel(self): - user = self.env['res.users'].search([('login','=',self.name),('active','=',True)]) + user = self.env['res.users'].search([('login', '=', self.name), ('active', '=', True)]) # find id of security grup user user_group_id = self.env['ir.model.data'].check_object_reference('affiliate_management', 'affiliate_security_user_group')[1] if self.user_id: @@ -105,15 +99,15 @@ class AffiliateRequest(models.Model): # for portal user # remove grup ids from user groups_id user.groups_id = [(3, user_group_id)] - user.groups_id = [(3, user_group_id+1)] + user.groups_id = [(3, user_group_id + 1)] user.partner_id.is_affiliate = False self.state = 'cancel' template_id = self.env.ref('affiliate_management.reject_affiliate_email') user_mail = self.env.user.partner_id.company_id.email or self.env.company.email - email_values = {"email_from":user_mail} + email_values = {"email_from": user_mail} db = request.session.get('db') - res = template_id.with_context({"db":db}).send_mail(self.id,force_send=True,email_values=email_values) + res = template_id.with_context({"db": db}).send_mail(self.id, force_send=True, email_values=email_values) return True def action_aproove(self): @@ -131,13 +125,10 @@ class AffiliateRequest(models.Model): template_id = self.env.ref('affiliate_management.welcome_affiliate_email') user_mail = self.env.user.partner_id.company_id.email or self.env.company.email db = request.session.get('db') - email_values = {"email_from":user_mail} - res = template_id.send_mail(self.id,force_send=True,email_values=email_values) + email_values = {"email_from": user_mail} + res = template_id.send_mail(self.id, force_send=True, email_values=email_values) return True - - - @api.model def _signup_create_user(self, values): """ create a new user from the template user """ @@ -164,14 +155,13 @@ class AffiliateRequest(models.Model): # copy may failed if asked login is not available. raise SignupError(ustr(e)) - def send_joining_mail(self,aff_request): + def send_joining_mail(self, aff_request): if aff_request.signup_valid: db = request.session.get('db') template_id = self.env.ref('affiliate_management.join_affiliate_email') user_mail = self.env.user.partner_id.company_id.email or self.env.company.email - email_values = {"email_from":user_mail} - res = template_id.send_mail(aff_request.id,force_send=True,email_values=email_values) - + email_values = {"email_from": user_mail} + res = template_id.send_mail(aff_request.id, force_send=True, email_values=email_values) def regenerate_token(self): self.signup_token = self.random_token() @@ -185,7 +175,7 @@ class AffiliateRequest(models.Model): # def _needaction_count(self, domain=None): # return len(self.env['affiliate.request'].search([('state','=','register')])) - def set_group_user(self,user_id): + def set_group_user(self, user_id): """Assign group to portal user""" UserObj = self.env['res.users'].sudo() user_group_id = self.env['ir.model.data']._xmlid_lookup('affiliate_management.affiliate_security_user_group')[2] @@ -199,13 +189,12 @@ class AffiliateRequest(models.Model): user.partner_id.res_affiliate_key = ''.join(random.choice('0123456789ABCDEFGHIJ0123456789KLMNOPQRSTUVWXYZ') for i in range(8)) user.partner_id.affiliate_program_id = self.env['affiliate.program'].search([])[-1].id - - def checkRequestExists(self,user_id): - exist = self.search([('user_id','=',user_id.id)]) + def checkRequestExists(self, user_id): + exist = self.search([('user_id', '=', user_id.id)]) return len(exist) and True or False - def checkRequeststate(self,user_id): - exist = self.search([('user_id','=',user_id.id)]) + def checkRequeststate(self, user_id): + exist = self.search([('user_id', '=', user_id.id)]) if len(exist): if exist.state == 'register': return 'pending' diff --git a/odex25_donation/affiliate_management/models/affiliate_tool.py b/odex25_donation/affiliate_management/models/affiliate_tool.py index 2a2ade696..b4fe69ea8 100644 --- a/odex25_donation/affiliate_management/models/affiliate_tool.py +++ b/odex25_donation/affiliate_management/models/affiliate_tool.py @@ -13,29 +13,29 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# -from odoo import models,fields,api,_ +from odoo.exceptions import UserError +from odoo import models, fields, api, _ import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError class AffiliateTool(models.TransientModel): _name = 'affiliate.tool' _description = "Affiliate Tool Model" _inherit = ['mail.thread'] - @api.depends('entity','aff_product_id','aff_category_id') + @api.depends('entity', 'aff_product_id', 'aff_category_id') def _make_link(self): key = "" if self.env['res.users'].browse(self.env.uid).res_affiliate_key: key = self.env['res.users'].browse(self.env.uid).res_affiliate_key type_url = "" if self.entity == 'product': - type_url = '/shop/product/'+str(self.aff_product_id.id) + type_url = '/shop/product/' + str(self.aff_product_id.id) if self.entity == 'category': - type_url = '/shop/category/'+str(self.aff_category_id.id) + type_url = '/shop/category/' + str(self.aff_category_id.id) base_url = self.env['ir.config_parameter'].get_param('web.base.url') if self.entity and (self.aff_product_id or self.aff_category_id): - self.link = base_url+type_url+"?aff_key="+key + self.link = base_url + type_url + "?aff_key=" + key else: self.link = "" @@ -45,10 +45,10 @@ class AffiliateTool(models.TransientModel): self.aff_category_id = "" self.link = "" name = fields.Char(string="Name") - entity = fields.Selection([('product','Product'),('category','Category')],string="Choose Entity",required=True) + entity = fields.Selection([('product', 'Product'), ('category', 'Category')], string="Choose Entity", required=True) aff_product_id = fields.Many2one('product.template', string='Product') - aff_category_id = fields.Many2one('product.public.category',string='Category') - link = fields.Char(string='Link',compute='_make_link') + aff_category_id = fields.Many2one('product.public.category', string='Category') + link = fields.Char(string='Link', compute='_make_link') user_id = fields.Many2one('res.users', string='current user', index=True, tracking=True, default=lambda self: self.env.user) @api.model_create_multi @@ -56,5 +56,5 @@ class AffiliateTool(models.TransientModel): new_url = None for vals in vals_list: vals['name'] = self.env['ir.sequence'].next_by_code('affiliate.tool') - new_url = super(AffiliateTool,self).create(vals) + new_url = super(AffiliateTool, self).create(vals) return new_url diff --git a/odex25_donation/affiliate_management/models/affiliate_visit.py b/odex25_donation/affiliate_management/models/affiliate_visit.py index 79c766f41..1b4cc509c 100644 --- a/odex25_donation/affiliate_management/models/affiliate_visit.py +++ b/odex25_donation/affiliate_management/models/affiliate_visit.py @@ -13,22 +13,22 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +import datetime +from datetime import timedelta +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ -from datetime import timedelta -import datetime class AffiliateVisit(models.Model): _name = "affiliate.visit" _order = "create_date desc" _description = "Affiliate Visit Model" - name = fields.Char(string = "Name",readonly='True') + name = fields.Char(string="Name", readonly='True') # @api.multi - @api.depends('affiliate_type','type_id') + @api.depends('affiliate_type', 'type_id') def _calc_type_name(self): for record in self: if record.affiliate_type == 'product': @@ -36,44 +36,43 @@ class AffiliateVisit(models.Model): if record.affiliate_type == 'category': record.type_name = record.env['product.public.category'].browse([record.type_id]).name - - affiliate_method = fields.Selection([("ppc","Pay Per Click"),("pps","Pay Per Sale")],string="Order Report",readonly='True',states={'draft': [('readonly', False)]},help="state of traffic either ppc or pps") - affiliate_type = fields.Selection([("product","Product"),("category","Category")],string="Affiliate Type",readonly='True',states={'draft': [('readonly', False)]},help="whether the ppc or pps is on product or category") - type_id = fields.Integer(string='Type Id',readonly='True',states={'draft': [('readonly', False)]},help="Id of product template on which ppc or pps traffic create") - type_name = fields.Char(string='Type Name',readonly='True',states={'draft': [('readonly', False)]},compute='_calc_type_name',help="Name of the product") - is_converted = fields.Boolean(string="Is Converted",readonly='True',states={'draft': [('readonly', False)]}) - sales_order_line_id = fields.Many2one("sale.order.line",readonly='True',states={'draft': [('readonly', False)]}) - affiliate_key = fields.Char(string="Key",readonly='True',states={'draft': [('readonly', False)]}) - affiliate_partner_id = fields.Many2one("res.partner",string="Affiliate",readonly='True',states={'draft': [('readonly', False)]}) - url = fields.Char(string="Url",readonly='True',states={'draft': [('readonly', False)]}) - ip_address = fields.Char(readonly='True',states={'draft': [('readonly', False)]}) + affiliate_method = fields.Selection([("ppc", "Pay Per Click"), ("pps", "Pay Per Sale")], string="Order Report", readonly='True', + states={'draft': [('readonly', False)]}, help="state of traffic either ppc or pps") + affiliate_type = fields.Selection([("product", "Product"), ("category", "Category")], string="Affiliate Type", readonly='True', + states={'draft': [('readonly', False)]}, help="whether the ppc or pps is on product or category") + type_id = fields.Integer(string='Type Id', readonly='True', states={'draft': [('readonly', False)]}, help="Id of product template on which ppc or pps traffic create") + type_name = fields.Char(string='Type Name', readonly='True', states={'draft': [('readonly', False)]}, compute='_calc_type_name', help="Name of the product") + is_converted = fields.Boolean(string="Is Converted", readonly='True', states={'draft': [('readonly', False)]}) + sales_order_line_id = fields.Many2one("sale.order.line", readonly='True', states={'draft': [('readonly', False)]}) + affiliate_key = fields.Char(string="Key", readonly='True', states={'draft': [('readonly', False)]}) + affiliate_partner_id = fields.Many2one("res.partner", string="Affiliate", readonly='True', states={'draft': [('readonly', False)]}) + url = fields.Char(string="Url", readonly='True', states={'draft': [('readonly', False)]}) + ip_address = fields.Char(readonly='True', states={'draft': [('readonly', False)]}) currency_id = fields.Many2one('res.currency', 'Currency', required=True, - default=lambda self: self.env.user.company_id.currency_id.id,readonly='True',states={'draft': [('readonly', False)]}) - convert_date = fields.Datetime(string='Date',readonly='True',states={'draft': [('readonly', False)]}) - price_total = fields.Monetary(string="Sale value",related='sales_order_line_id.price_total',states={'draft': [('readonly', False)]},help="Total sale value of product" ) + default=lambda self: self.env.user.company_id.currency_id.id, readonly='True', states={'draft': [('readonly', False)]}) + convert_date = fields.Datetime(string='Date', readonly='True', states={'draft': [('readonly', False)]}) + price_total = fields.Monetary(string="Sale value", related='sales_order_line_id.price_total', states={'draft': [('readonly', False)]}, help="Total sale value of product") unit_price = fields.Float(string="Product Unit Price", related='sales_order_line_id.price_unit', readonly='True', - states={'draft': [('readonly', False)]},help="price unit of the product") - commission_amt = fields.Float(readonly='True',states={'draft': [('readonly', False)]}) - affiliate_program_id = fields.Many2one('affiliate.program',string='Program',readonly='True',states={'draft': [('readonly', False)]}) - amt_type = fields.Char(string='Commission Matrix',readonly='True',states={'draft': [('readonly', False)]},help="Commission Matrix on which commission value calculated") - act_invoice_id = fields.Many2one("account.move", string='Act Invoice id',readonly='True',states={'draft': [('readonly', False)]}) + states={'draft': [('readonly', False)]}, help="price unit of the product") + commission_amt = fields.Float(readonly='True', states={'draft': [('readonly', False)]}) + affiliate_program_id = fields.Many2one('affiliate.program', string='Program', readonly='True', states={'draft': [('readonly', False)]}) + amt_type = fields.Char(string='Commission Matrix', readonly='True', states={'draft': [('readonly', False)]}, help="Commission Matrix on which commission value calculated") + act_invoice_id = fields.Many2one("account.move", string='Act Invoice id', readonly='True', states={'draft': [('readonly', False)]}) state = fields.Selection([ ('draft', 'Draft'), ('cancel', 'Cancel'), ('confirm', 'Confirm'), ('invoice', 'Invoiced'), ('paid', 'Paid'), - ], string='Status', readonly=True, default='draft' ) - product_quantity = fields.Integer(readonly='True',states={'draft': [('readonly', False)]}) - - + ], string='Status', readonly=True, default='draft') + product_quantity = fields.Integer(readonly='True', states={'draft': [('readonly', False)]}) @api.model_create_multi def create(self, vals_list): new_visit = None for vals in vals_list: vals['name'] = self.env['ir.sequence'].next_by_code('affiliate.visit') - new_visit = super(AffiliateVisit,self).create(vals) + new_visit = super(AffiliateVisit, self).create(vals) return new_visit # button on view action @@ -86,14 +85,14 @@ class AffiliateVisit(models.Model): check_enable_ppc = self.env['res.config.settings'].sudo().website_constant().get('enable_ppc') if self.affiliate_method != 'ppc' and not self.sales_order_line_id: - raise UserError("Order is not present in visit %s."%self.name) + raise UserError("Order is not present in visit %s." % self.name) if self.affiliate_method != 'ppc' and not self.price_total: raise UserError("Sale value must be greater than zero.") - if self.affiliate_method == 'ppc' and (not check_enable_ppc) : + if self.affiliate_method == 'ppc' and (not check_enable_ppc): raise UserError("Pay per click is disable, so you can't confirm it's commission") self.state = 'confirm' - status = self._get_rate(self.affiliate_method , self.affiliate_type, self.type_id ) + status = self._get_rate(self.affiliate_method, self.affiliate_type, self.type_id) if status.get('is_error'): raise UserError(status['message']) return True @@ -105,44 +104,43 @@ class AffiliateVisit(models.Model): return True - # scheduler according to the scheduler define in data automated scheduler @api.model def process_scheduler_queue(self): - users_all = self.env['res.users'].search([('is_affiliate','=',True)]) + users_all = self.env['res.users'].search([('is_affiliate', '=', True)]) ConfigValues = self.env['res.config.settings'].sudo().website_constant() payment_day = ConfigValues.get('payment_day') threshold_amt = ConfigValues.get('minimum_amt') # make the date of current month of setting date payment_date = datetime.date(datetime.date.today().year, datetime.date.today().month, payment_day) for u in users_all: - visits = self.search([('state','=','confirm'),('affiliate_partner_id','=',u.partner_id.id)]) + visits = self.search([('state', '=', 'confirm'), ('affiliate_partner_id', '=', u.partner_id.id)]) if payment_date and visits: visits = visits.filtered(lambda r: fields.Date.from_string(r.create_date) <= payment_date) - _logger.info("*****filter- visits=%r******",visits) + _logger.info("*****filter- visits=%r******", visits) - _logger.info("****before******before method***visits**%r*******",visits) + _logger.info("****before******before method***visits**%r*******", visits) visits = self.check_enable_ppc_visits(visits) # function to filter the visits if ppc is enable or disable accordingly - _logger.info("*****after*****after method***visits**%r*******",visits) + _logger.info("*****after*****after method***visits**%r*******", visits) total_comm_per_user = 0 if visits: for v in visits: total_comm_per_user = total_comm_per_user + v.commission_amt if total_comm_per_user >= threshold_amt and payment_date: - dic={ - 'name':"Total earn commission on ppc and pps", - 'quantity':1, - 'price_unit':total_comm_per_user, - 'product_id':ConfigValues.get('aff_product_id'), + dic = { + 'name': "Total earn commission on ppc and pps", + 'quantity': 1, + 'price_unit': total_comm_per_user, + 'product_id': ConfigValues.get('aff_product_id'), } invoice_dict = [ { 'invoice_line_ids': [(0, 0, dic)], 'move_type': 'in_invoice', - 'partner_id':u.partner_id.id, - 'invoice_date':fields.Datetime.now().date() + 'partner_id': u.partner_id.id, + 'invoice_date': fields.Datetime.now().date() } ] @@ -152,8 +150,7 @@ class AffiliateVisit(models.Model): v.act_invoice_id = inv_id.id return True - - def check_enable_ppc_visits(self,visits): + def check_enable_ppc_visits(self, visits): check_enable_ppc = self.env['res.config.settings'].sudo().website_constant().get('enable_ppc') if check_enable_ppc: return visits @@ -161,8 +158,6 @@ class AffiliateVisit(models.Model): visits = visits.filtered(lambda v: v.affiliate_method == 'pps') return visits - - # method call from server action @api.model def create_invoice(self): @@ -173,62 +168,59 @@ class AffiliateVisit(models.Model): act_invoice = self.env['account.move'] # check the first visit of context is ppc or pps and enable pps affiliate_method_type = self.browse([aff_vst[0]]).affiliate_method - if affiliate_method_type == 'ppc' and (not check_enable_ppc) : + if affiliate_method_type == 'ppc' and (not check_enable_ppc): raise UserError("Pay per click is disable, so you can't generate it's invoice") - invoice_ids =[] + invoice_ids = [] for v in aff_vst: vst = self.browse([v]) - # [[0, 'virtual_754', {'sequence': 10, 'product_id': 36, 'name': '[Deposit] Deposit', 'account_id': 21, 'analytic_account_id': False, 'analytic_tag_ids': [[6, False, []]], - # 'quantity': 1, 'product_uom_id': 1, 'price_unit': 150, 'discount': 0, 'tax_ids': [[6, False, [1]]] + # [[0, 'virtual_754', {'sequence': 10, 'product_id': 36, 'name': '[Deposit] Deposit', 'account_id': 21, 'analytic_account_id': False, 'analytic_tag_ids': [[6, False, []]], + # 'quantity': 1, 'product_uom_id': 1, 'price_unit': 150, 'discount': 0, 'tax_ids': [[6, False, [1]]] if vst.state == 'confirm': # ********** creating invoice line ********************* if vst.sales_order_line_id: - dic={ - 'name':"Type "+vst.affiliate_type+" on Pay Per Sale ", - 'quantity':1, - 'price_unit':vst.commission_amt, - # 'move_id':inv_id.id, - # 'product_id':ConfigValues.get('aff_product_id'), - } + dic = { + 'name': "Type " + vst.affiliate_type + " on Pay Per Sale ", + 'quantity': 1, + 'price_unit': vst.commission_amt, + # 'move_id':inv_id.id, + # 'product_id':ConfigValues.get('aff_product_id'), + } else: - dic={ - 'name':"Type "+vst.affiliate_type+" on Pay Per Click ", - 'price_unit':vst.commission_amt, - 'quantity':1, - # 'product_id':ConfigValues.get('aff_product_id'), - } + dic = { + 'name': "Type " + vst.affiliate_type + " on Pay Per Click ", + 'price_unit': vst.commission_amt, + 'quantity': 1, + # 'product_id':ConfigValues.get('aff_product_id'), + } invoice_dict = [ - { - 'invoice_line_ids': [(0, 0, dic)], - 'move_type': 'in_invoice', - 'partner_id':vst.affiliate_partner_id.id, - 'invoice_date':fields.Datetime.now().date() - }] + { + 'invoice_line_ids': [(0, 0, dic)], + 'move_type': 'in_invoice', + 'partner_id': vst.affiliate_partner_id.id, + 'invoice_date': fields.Datetime.now().date() + }] line = self.env['account.move'].create(invoice_dict) vst.state = 'invoice' vst.act_invoice_id = line.id invoice_ids.append(line) - msg = str(len(invoice_ids))+' records has been invoiced out of '+str(len(aff_vst)) + msg = _('%s records has been invoiced out of %s') % (len(invoice_ids), len(aff_vst)) - partial_id = self.env['wk.wizard.message'].create({'text': msg}) return { - 'name': "Message", - 'view_mode': 'form', - 'view_id': False, - 'res_model': 'wk.wizard.message', - 'res_id': partial_id.id, - 'type': 'ir.actions.act_window', - 'nodestroy': True, - 'target': 'new', + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'message': msg, + 'next': {'type': 'ir.actions.act_window_close'}, + } } - - def _get_rate(self,affiliate_method,affiliate_type,type_id): - #_get_rate() methods arguments (pps,product,product_id) or (ppc,product,product_id) or (ppc,category,category_id) + def _get_rate(self, affiliate_method, affiliate_type, type_id): + # _get_rate() methods arguments (pps,product,product_id) or (ppc,product,product_id) or (ppc,category,category_id) # check product.id in product.template # check category.id in product.public.category product_exists = False @@ -245,117 +237,111 @@ class AffiliateVisit(models.Model): if affiliate_type == 'category': category_exists = self.env['product.public.category'].browse([type_id]) - if affiliate_method == 'ppc' and product_exists or category_exists: # pay per click - commission = from_currency._convert(self.affiliate_program_id.amount_ppc_fixed,self.affiliate_program_id.currency_id, company, fields.Date.today()) + if affiliate_method == 'ppc' and product_exists or category_exists: # pay per click + commission = from_currency._convert(self.affiliate_program_id.amount_ppc_fixed, self.affiliate_program_id.currency_id, company, fields.Date.today()) commission_type = 'fixed' self.commission_amt = commission else: - # pay per sale - if affiliate_method == 'pps' and product_exists : - #for pps_type simple + # pay per sale + if affiliate_method == 'pps' and product_exists: + # for pps_type simple if self.affiliate_program_id.pps_type == 's': if self.affiliate_program_id.matrix_type == 'f': # fixed - amt = from_currency._convert(self.affiliate_program_id.amount,self.affiliate_program_id.currency_id, company, fields.Date.today()) - commission = amt * self.product_quantity + amt = from_currency._convert(self.affiliate_program_id.amount, self.affiliate_program_id.currency_id, company, fields.Date.today()) + commission = amt * self.product_quantity commission_type = 'fixed' else: - if self.affiliate_program_id.matrix_type == 'p' and (not self.affiliate_program_id.amount >100): # percentage - amt_product = from_currency._convert(self.price_total,self.affiliate_program_id.currency_id, company, fields.Date.today()) - commission = (amt_product * self.affiliate_program_id.amount/100) + if self.affiliate_program_id.matrix_type == 'p' and (not self.affiliate_program_id.amount > 100): # percentage + amt_product = from_currency._convert(self.price_total, self.affiliate_program_id.currency_id, company, fields.Date.today()) + commission = (amt_product * self.affiliate_program_id.amount / 100) commission_type = 'percentage' else: - response={ - 'is_error':1, - 'message':'Percenatge amount is greater than 100', + response = { + 'is_error': 1, + 'message': 'Percenatge amount is greater than 100', } else: # for pps type advance (advance depends upon price list) - if self.affiliate_program_id.pps_type == 'a' and product_exists:#for pps_type advance - adv_commision_amount,commission,commission_type = self.advance_pps_type_calc() + if self.affiliate_program_id.pps_type == 'a' and product_exists: # for pps_type advance + adv_commision_amount, commission, commission_type = self.advance_pps_type_calc() # adv_commision_amount = is a amount if advance commission # commission = is a amount which is earned by commisiion commission = commission * self.product_quantity - _logger.info("----commision_value-%r--------commision_value_type-%r------",commission,commission_type) + _logger.info("----commision_value-%r--------commision_value_type-%r------", commission, commission_type) _logger.info('================advance_pps_type_calc===============') if commission and commission_type: - _logger.info("---22----adv_commision_amount--%r--commision_value-%r--------commision_value_type-%r------",adv_commision_amount,commission,commission_type) + _logger.info("---22----adv_commision_amount--%r--commision_value-%r--------commision_value_type-%r------", adv_commision_amount, commission, commission_type) else: - response={ - 'is_error':1, - 'message':'No commission Category Found for this product..' + response = { + 'is_error': 1, + 'message': 'No commission Category Found for this product..' } - else: - response={ - 'is_error':1, - 'message':'pps_type is advance', + response = { + 'is_error': 1, + 'message': 'pps_type is advance', } else: - response={ - 'is_error':1, - 'message':'Affilite method is niether ppc nor pps or affiliate type is absent(product or category)', + response = { + 'is_error': 1, + 'message': 'Affilite method is niether ppc nor pps or affiliate type is absent(product or category)', } else: - response={ - 'is_error':1, - 'message':'Program is absent in visit', + response = { + 'is_error': 1, + 'message': 'Program is absent in visit', } if commission: self.commission_amt = commission # self.amt_type = commission_type if commission_type == 'fixed' and affiliate_method == 'ppc': - self.amt_type = self.affiliate_program_id.currency_id.symbol+ str(commission) + self.amt_type = self.affiliate_program_id.currency_id.symbol + str(commission) if commission_type == 'percentage' and affiliate_method == 'ppc': - self.amt_type = str(self.affiliate_program_id.amount_ppc_fixed)+ '%' - #for pps + self.amt_type = str(self.affiliate_program_id.amount_ppc_fixed) + '%' + # for pps if commission_type == 'percentage' and self.affiliate_program_id.pps_type == 's': - self.amt_type = str(self.affiliate_program_id.amount) +"%" + self.amt_type = str(self.affiliate_program_id.amount) + "%" if commission_type == 'fixed' and affiliate_method == 'pps' and self.affiliate_program_id.pps_type == 's': - self.amt_type = self.affiliate_program_id.currency_id.symbol + str(commission) + self.amt_type = self.affiliate_program_id.currency_id.symbol + str(commission) if commission_type == 'fixed' and affiliate_method == 'pps' and self.affiliate_program_id.pps_type == 'a': - self.amt_type = self.affiliate_program_id.currency_id.symbol + str(adv_commision_amount)+" advance" + self.amt_type = self.affiliate_program_id.currency_id.symbol + str(adv_commision_amount) + " advance" if commission_type == 'percentage' and affiliate_method == 'pps' and self.affiliate_program_id.pps_type == 'a': - self.amt_type = str(adv_commision_amount)+"%"+" advance" - response={ - 'is_error':0, - 'message':'Commission successfully added', - 'comm_type':commission_type, - 'comm_amt' : commission + self.amt_type = str(adv_commision_amount) + "%" + " advance" + response = { + 'is_error': 0, + 'message': 'Commission successfully added', + 'comm_type': commission_type, + 'comm_amt': commission } else: if response.get('is_error') == 1: - response={ - 'is_error':1, - 'message':response.get('message'), + response = { + 'is_error': 1, + 'message': response.get('message'), } return response - - def advance_pps_type_calc(self): - adv_commision_amount,commision_value,commision_value_type = self.env["advance.commision"].calc_commision_adv(self.affiliate_program_id.advance_commision_id.id, self.type_id , self.unit_price) + adv_commision_amount, commision_value, commision_value_type = self.env["advance.commision"].calc_commision_adv(self.affiliate_program_id.advance_commision_id.id, self.type_id, self.unit_price) # argument of calc_commision_adv(adv_comm_id, product_id on which commision apply , price of product) # return adv_commision_amount ,commision_value, commision_value_type - _logger.info("---11----adv_commision_amount----commision_value-%r--------commision_value_type-%r------",adv_commision_amount,commision_value,commision_value_type) + _logger.info("---11----adv_commision_amount----commision_value-%r--------commision_value_type-%r------", adv_commision_amount, commision_value, commision_value_type) # return commision_value,commision_value_type - return adv_commision_amount,commision_value,commision_value_type - - - + return adv_commision_amount, commision_value, commision_value_type @api.model def process_ppc_maturity_scheduler_queue(self): _logger.info("-----Inside----process_ppc_maturity_scheduler_queue-----------") check_enable_ppc = self.env['res.config.settings'].sudo().website_constant().get('enable_ppc') - all_ppc_visits = self.search([('affiliate_method','=','ppc'),('state','=','draft')]) + all_ppc_visits = self.search([('affiliate_method', '=', 'ppc'), ('state', '=', 'draft')]) if check_enable_ppc: for visit in all_ppc_visits: visit.action_confirm() diff --git a/odex25_donation/affiliate_management/models/odoo_http.py b/odex25_donation/affiliate_management/models/odoo_http.py index 94ae72ec1..20920a336 100644 --- a/odex25_donation/affiliate_management/models/odoo_http.py +++ b/odex25_donation/affiliate_management/models/odoo_http.py @@ -1,13 +1,13 @@ +from odoo.http import root, db_filter, db_list +from odoo.tools.func import lazy_property from odoo import http import logging from odoo.http import request _logger = logging.getLogger(__name__) -from odoo.tools.func import lazy_property -from odoo.http import root, db_filter, db_list DEFAULT_SESSION = { 'context': { - #'lang': request.default_lang() # must be set at runtime + # 'lang': request.default_lang() # must be set at runtime }, 'db': None, 'debug': '', @@ -21,11 +21,10 @@ DEFAULT_SESSION = { } - def _get_session_and_dbname(self): sid = (self.httprequest.args.get('session_id') - or self.httprequest.headers.get("X-Openerp-Session-Id")) + or self.httprequest.headers.get("X-Openerp-Session-Id")) db_from_request = self.httprequest.values.get("db") or self.httprequest.headers.get("db") if sid: is_explicit = True @@ -40,8 +39,6 @@ def _get_session_and_dbname(self): session.sid = sid # in case the session was not persisted session.is_explicit = is_explicit - - for key, val in DEFAULT_SESSION.items(): session.setdefault(key, val) if not session.context.get('lang'): @@ -67,4 +64,5 @@ def _get_session_and_dbname(self): session.is_dirty = False return session, dbname + http.Request._get_session_and_dbname = _get_session_and_dbname diff --git a/odex25_donation/affiliate_management/models/res_partner_inherit.py b/odex25_donation/affiliate_management/models/res_partner_inherit.py index dd536708f..11756a13b 100644 --- a/odex25_donation/affiliate_management/models/res_partner_inherit.py +++ b/odex25_donation/affiliate_management/models/res_partner_inherit.py @@ -13,38 +13,35 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +import string +import random +import datetime +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ -import random, string -import datetime class ResPartnerInherit(models.Model): _inherit = 'res.partner' _description = "ResPartner Inherit Model" - is_affiliate = fields.Boolean(default=False) res_affiliate_key = fields.Char(string="Affiliate key") - affiliate_program_id = fields.Many2one("affiliate.program",string="Program") + affiliate_program_id = fields.Many2one("affiliate.program", string="Program") pending_amt = fields.Float(compute='_compute_pending_amt', string='Pending Amount') approved_amt = fields.Float(compute='_compute_approved_amt', string='Approved Amount') - - - def toggle_active(self): for o in self: if o.is_affiliate: o.is_affiliate = False else: o.is_affiliate = True - return super(ResPartnerInherit,self).toggle_active() + return super(ResPartnerInherit, self).toggle_active() def _compute_pending_amt(self): for s in self: - visits = s.env['affiliate.visit'].search([('state','=','confirm'),('affiliate_partner_id','=',s.id)]) + visits = s.env['affiliate.visit'].search([('state', '=', 'confirm'), ('affiliate_partner_id', '=', s.id)]) amt = 0 for v in visits: amt = amt + v.commission_amt @@ -52,7 +49,7 @@ class ResPartnerInherit(models.Model): def _compute_approved_amt(self): for s in self: - visits = s.env['affiliate.visit'].search([('state','=','invoice'),('affiliate_partner_id','=',s.id)]) + visits = s.env['affiliate.visit'].search([('state', '=', 'invoice'), ('affiliate_partner_id', '=', s.id)]) amt = 0 for v in visits: amt = amt + v.commission_amt @@ -62,16 +59,15 @@ class ResPartnerInherit(models.Model): ran = ''.join(random.choice('0123456789ABCDEFGHIJ0123456789KLMNOPQRSTUVWXYZ') for i in range(8)) self.res_affiliate_key = ran - @api.model_create_multi - def create(self,vals_list): + def create(self, vals_list): aff_prgm = None new_res_partner = None for vals in vals_list: - aff_prgm = self.env['affiliate.program'].search([])[-1].id if len(self.env['affiliate.program'].search([]))>0 else '' + aff_prgm = self.env['affiliate.program'].search([])[-1].id if len(self.env['affiliate.program'].search([])) > 0 else '' if vals.get('is_affiliate'): vals.update({ - 'affiliate_program_id':aff_prgm + 'affiliate_program_id': aff_prgm }) - new_res_partner = super(ResPartnerInherit,self).create(vals) + new_res_partner = super(ResPartnerInherit, self).create(vals) return new_res_partner diff --git a/odex25_donation/affiliate_management/models/res_user_inherit.py b/odex25_donation/affiliate_management/models/res_user_inherit.py index bf28275d4..9debdf29c 100644 --- a/odex25_donation/affiliate_management/models/res_user_inherit.py +++ b/odex25_donation/affiliate_management/models/res_user_inherit.py @@ -13,18 +13,18 @@ # You should have received a copy of the License along with this program. # If not, see ; ################################################################################# +from odoo import models, fields, api, _ +import string +import random +from ast import literal_eval +from odoo.exceptions import UserError import logging _logger = logging.getLogger(__name__) -from odoo.exceptions import UserError -from odoo import models, fields,api,_ -import random, string -from ast import literal_eval class ResUserInherit(models.Model): - _inherit = 'res.users' - _inherits = {'res.partner': 'partner_id'} - _description = "ResUser Inherit Model" - - res_affiliate_key = fields.Char(related='partner_id.res_affiliate_key',string='Partner Affiliate Key', inherited=True) + _inherit = 'res.users' + _inherits = {'res.partner': 'partner_id'} + _description = "ResUser Inherit Model" + res_affiliate_key = fields.Char(related='partner_id.res_affiliate_key', string='Partner Affiliate Key', inherited=True) diff --git a/odex25_donation/affiliate_management/security/affiliate_security.xml b/odex25_donation/affiliate_management/security/affiliate_security.xml index 086b352a0..7739a2213 100644 --- a/odex25_donation/affiliate_management/security/affiliate_security.xml +++ b/odex25_donation/affiliate_management/security/affiliate_security.xml @@ -1,101 +1,99 @@ - + - - Affiliate Category - + + Affiliate Category + - - User - - + + User + + - - Manager - - - - + + Manager + + + + - + - + - - Affiliate managemnt Records for User - - - [("id", '=',user.partner_id.id)] + + Affiliate managemnt Records for User + + + [("id", '=',user.partner_id.id)] - + - - Affiliate managemnt visits for User - - - [("affiliate_partner_id", '=',user.partner_id.id)] + + Affiliate managemnt visits for User + + + [("affiliate_partner_id", '=',user.partner_id.id)] - - - Affiliate managemnt account invoice for User - - - [("partner_id", '=',user.partner_id.id)] + + + Affiliate managemnt account invoice for User + + + [("partner_id", '=',user.partner_id.id)] - + - - Affiliate managemnt Image for User - - - [(1, '=',1)] - + + Affiliate managemnt Image for User + + + [(1, '=',1)] + - - - Affiliate managemnt visits for Manager - - - [(1, '=',1)] + + + Affiliate managemnt visits for Manager + + + [(1, '=',1)] - + - - Affiliate managemnt request for Manager - - - [(1, '=',1)] + + Affiliate managemnt request for Manager + + + [(1, '=',1)] - + - - Affiliate managemnt account invoice for Manager - - - [(1, '=',1)] + + Affiliate managemnt account invoice for Manager + + + [(1, '=',1)] - - - manager managemnt Records for manager - - - [(1, '=',1)] - + + + manager managemnt Records for manager + + + [(1, '=',1)] + - - manager advance commision for manager - - - [(1, '=',1)] - + + manager advance commision for manager + + + [(1, '=',1)] + - + - - - + \ No newline at end of file diff --git a/odex25_donation/affiliate_management/static/loader/jquery.loader.js b/odex25_donation/affiliate_management/static/loader/jquery.loader.js index 3932c6908..44a071c20 100644 --- a/odex25_donation/affiliate_management/static/loader/jquery.loader.js +++ b/odex25_donation/affiliate_management/static/loader/jquery.loader.js @@ -8,87 +8,88 @@ * usage : $.loader(); * $.loader(options) -> options = * { - * + * * } * * To close loader : $.loader("close"); * */ var jQueryLoaderOptions = null; -(function($) { - $.loader = function(option){ - switch(option) - { - case 'close': - if(jQueryLoaderOptions){ - if($("#"+jQueryLoaderOptions.id)){ - $("#"+jQueryLoaderOptions.id +", #"+jQueryLoaderOptions.background.id).remove(); - } - } - return; - case 'setContent': - if(jQueryLoaderOptions){ - if($("#"+jQueryLoaderOptions.id)){ - if(arguments.length == 2) - { - $("#"+jQueryLoaderOptions.id).html(arguments[1]); - }else{ - if(console){ - console.error("setContent method must have 2 arguments $.loader('setContent', 'new content');"); - }else{ - alert("setContent method must have 2 arguments $.loader('setContent', 'new content');"); - } - } - } - } - return; - default: - var options = $.extend({ - content:"Loading ...", - className:'loader', - id:'jquery-loader', - height:60, - width:200, - zIndex:30000, - background:{ - opacity:0.4, - id:'jquery-loader-background' - } - }, option); - } - jQueryLoaderOptions = options; - var maskHeight = $(document).height(); - var maskWidth = $(window).width(); - var bgDiv = $('
'); - bgDiv.css({ - zIndex:options.zIndex, - position:'absolute', - top:'0px', - left:'0px', - width:maskWidth, - height:maskHeight, - opacity:options.background.opacity - }); +(function ($) { + $.loader = function (option) { + switch (option) { + case "close": + if (jQueryLoaderOptions) { + if ($("#" + jQueryLoaderOptions.id)) { + $("#" + jQueryLoaderOptions.id + ", #" + jQueryLoaderOptions.background.id).remove(); + } + } + return; + case "setContent": + if (jQueryLoaderOptions) { + if ($("#" + jQueryLoaderOptions.id)) { + if (arguments.length == 2) { + $("#" + jQueryLoaderOptions.id).html(arguments[1]); + } else { + if (console) { + console.error("setContent method must have 2 arguments $.loader('setContent', 'new content');"); + } else { + alert("setContent method must have 2 arguments $.loader('setContent', 'new content');"); + } + } + } + } + return; + default: + var options = $.extend( + { + content: "Loading ...", + className: "loader", + id: "jquery-loader", + height: 60, + width: 200, + zIndex: 30000, + background: { + opacity: 0.4, + id: "jquery-loader-background", + }, + }, + option + ); + } + jQueryLoaderOptions = options; + var maskHeight = $(document).height(); + var maskWidth = $(window).width(); + var bgDiv = $('
'); + bgDiv.css({ + zIndex: options.zIndex, + position: "absolute", + top: "0px", + left: "0px", + width: maskWidth, + height: maskHeight, + opacity: options.background.opacity, + }); - bgDiv.appendTo("body"); - if(jQuery.bgiframe){ - bgDiv.bgiframe(); - } - var div = $('
'); - div.css({ - zIndex:options.zIndex+1, - width:options.width, - height:options.height - }); - div.appendTo('body'); - div.center(); - div.html(options.content); - //$(options.content).appendTo(div); - }; - $.fn.center = function () { - this.css("position","absolute"); - this.css("top", ( $(window).height() - this.outerHeight() ) / 2+$(window).scrollTop() + "px"); - this.css("left", ( $(window).width() - this.outerWidth() ) / 2+$(window).scrollLeft() + "px"); - return this; - }; -})(jQuery); \ No newline at end of file + bgDiv.appendTo("body"); + if (jQuery.bgiframe) { + bgDiv.bgiframe(); + } + var div = $('
'); + div.css({ + zIndex: options.zIndex + 1, + width: options.width, + height: options.height, + }); + div.appendTo("body"); + div.center(); + div.html(options.content); + //$(options.content).appendTo(div); + }; + $.fn.center = function () { + this.css("position", "absolute"); + this.css("top", ($(window).height() - this.outerHeight()) / 2 + $(window).scrollTop() + "px"); + this.css("left", ($(window).width() - this.outerWidth()) / 2 + $(window).scrollLeft() + "px"); + return this; + }; +})(jQuery); diff --git a/odex25_donation/affiliate_management/static/src/js/validation.js b/odex25_donation/affiliate_management/static/src/js/validation.js index 469ac3cc1..09284b979 100644 --- a/odex25_donation/affiliate_management/static/src/js/validation.js +++ b/odex25_donation/affiliate_management/static/src/js/validation.js @@ -1,193 +1,167 @@ -odoo.define('affiliate_management.validation',function(require){ -"use strict"; +odoo.define("affiliate_management.validation", function (require) { + "use strict"; -var core = require('web.core'); -var ajax = require('web.ajax'); + var core = require("web.core"); + var ajax = require("web.ajax"); -var _t = core._t; + var _t = core._t; - // js for choose button in step 2 of generate product url + // js for choose button in step 2 of generate product url -// term_condition - - - - - - - - - - -$(document).ready(function() { - $('.signup-btn').on('click',function(){ - var c = $('#tc-signup-checkbox').is(':checked'); - console.log(c); - if (c == false) - { - - $('#term_condition_error').show(); - return false; - } - }); - - - - $( ".button_image_generate_url" ).hide(); - $('.o_form_radio').on('click',function(){ - $('[id^=product-text_]').hide(); - console.log(this.getAttribute('id').split("_")[1]) - var radio_id = this.getAttribute('id').split("_")[1]; - $( ".button_image_generate_url" ).hide(); - $('#image_'+radio_id).show(); - - }); - $('.o_form_radio_product').on('click',function(){ - $( ".button_image_generate_url" ).hide(); - var product_text_id =$("#product-text_"+this.id.split("_")[1]); - $(product_text_id).show(); - $( ".product_image" ).show(); - }); - - -// copy the text from clipboard - var copyBtn - var input - - $('[id^=copy-btn_]').on('click',function(){ - console.log("start") - copyBtn = this; - input = $("#copy-me_"+this.id.split("_")[1]); - console.log("input",input) - copyToClipboard(); - $('[id^=copy-btn_]').text('Copy to Clipboard') - $(this).text('copied'); - console.log("copy button clicked") - }); - - function copyToClipboardFF(text) { - window.prompt ("Copy to clipboard: Ctrl C, Enter", text); - } - - function copyToClipboard() { - var success = true, - range = document.createRange(), - selection; - - // For IE. - if (window.clipboardData) { - console.log("clipboard") - window.clipboardData.setData("Text", input.val()); - } else { - // Create a temporary element off screen. - var tmpElem = $('
'); - tmpElem.css({ - position: "absolute", - left: "-1000px", - top: "-1000px", - }); - // Add the input value to the temp element. - tmpElem.text(input.val()); - console.log("tmpElem",tmpElem) - $("body").append(tmpElem); - // Select temp element. - range.selectNodeContents(tmpElem.get(0)); - console.log("range",range) - selection = window.getSelection (); - selection.removeAllRanges (); - console.log("remove range") - selection.addRange (range); - // Lets copy. - try { - success = document.execCommand ("copy", false, null); - } - catch (e) { - copyToClipboardFF(input.val()); - } - if (success) { - // alert ("The text is on the clipboard, try to paste it!"); - // remove temp element. - tmpElem.remove(); - } - } -} - - -// copy link for affiliate link generator -$("#link_copy_button").click(function(){ - - // Code to change the text of copy button to copied and again change it to copy - $(this).text('Copied'); - setTimeout(function() { - $("#link_copy_button").text('Copy'); - }, 2000); - $("#copy_link").show(); - $("#copy_link").select(); - document.execCommand('copy'); - $("#copy_link").hide(); -}); -// copy html code from text area -var clicked = false; -$("#banner_copy_button").click(function(){ - $("#banner_html_code").select(); - document.execCommand('copy'); - $(this).text('Copied'); - setTimeout(function() { - $("#banner_copy_button").text('Copy'); - $("#banner_html_code").blur(); - }, 2000); - if (clicked == false) - { - $('#step3').hide(); - $('#step3').after( - "" - ); - clicked = true; - } -}); - -$("#later_button").click(function(){ - $("#aff_req_btn").hide(); -}); - - - - -$('[id^=yes_btn_uid_]').on('click',function(){ - var uid = this.id.split("_")[3]; - ajax.jsonRpc("/affiliate/request", 'call',{'user_id': uid}).then(function (result){ - console.log(result); - if (result) - { - // $("#aff_req_btn").replaceWith( "

Your Request has been submitted sucessfully. Soon you will be notify by email.

"); - $("#aff_req_btn").hide(); - $(".alert_msg_banner").show(); + // term_condition + $(document).ready(function () { + $(".signup-btn").on("click", function () { + var c = $("#tc-signup-checkbox").is(":checked"); + console.log(c); + if (c == false) { + $("#term_condition_error").show(); + return false; } - else{ + }); + $(".button_image_generate_url").hide(); + $(".o_form_radio").on("click", function () { + $("[id^=product-text_]").hide(); + console.log(this.getAttribute("id").split("_")[1]); + var radio_id = this.getAttribute("id").split("_")[1]; + $(".button_image_generate_url").hide(); + $("#image_" + radio_id).show(); + }); + $(".o_form_radio_product").on("click", function () { + $(".button_image_generate_url").hide(); + var product_text_id = $("#product-text_" + this.id.split("_")[1]); + $(product_text_id).show(); + $(".product_image").show(); + }); + + // copy the text from clipboard + var copyBtn; + var input; + + $("[id^=copy-btn_]").on("click", function () { + console.log("start"); + copyBtn = this; + input = $("#copy-me_" + this.id.split("_")[1]); + console.log("input", input); + copyToClipboard(); + $("[id^=copy-btn_]").text("Copy to Clipboard"); + $(this).text("copied"); + console.log("copy button clicked"); + }); + + function copyToClipboardFF(text) { + window.prompt("Copy to clipboard: Ctrl C, Enter", text); + } + + function copyToClipboard() { + var success = true, + range = document.createRange(), + selection; + + // For IE. + if (window.clipboardData) { + console.log("clipboard"); + window.clipboardData.setData("Text", input.val()); + } else { + // Create a temporary element off screen. + var tmpElem = $("
"); + tmpElem.css({ + position: "absolute", + left: "-1000px", + top: "-1000px", + }); + // Add the input value to the temp element. + tmpElem.text(input.val()); + console.log("tmpElem", tmpElem); + $("body").append(tmpElem); + // Select temp element. + range.selectNodeContents(tmpElem.get(0)); + console.log("range", range); + selection = window.getSelection(); + selection.removeAllRanges(); + console.log("remove range"); + selection.addRange(range); + // Lets copy. + try { + success = document.execCommand("copy", false, null); + } catch (e) { + copyToClipboardFF(input.val()); } - }); - }); + if (success) { + // alert ("The text is on the clipboard, try to paste it!"); + // remove temp element. + tmpElem.remove(); + } + } + } -function isValidEmailAddress(emailAddress) { - // var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i; - var pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/i; - return pattern.test(emailAddress); -}; + // copy link for affiliate link generator + $("#link_copy_button").click(function () { + // Code to change the text of copy button to copied and again change it to copy + $(this).text("Copied"); + setTimeout(function () { + $("#link_copy_button").text("Copy"); + }, 2000); + $("#copy_link").show(); + $("#copy_link").select(); + document.execCommand("copy"); + $("#copy_link").hide(); + }); + // copy html code from text area + var clicked = false; + $("#banner_copy_button").click(function () { + $("#banner_html_code").select(); + document.execCommand("copy"); + $(this).text("Copied"); + setTimeout(function () { + $("#banner_copy_button").text("Copy"); + $("#banner_html_code").blur(); + }, 2000); + if (clicked == false) { + $("#step3").hide(); + $("#step3").after(""); + clicked = true; + } + }); - $("#join-btn").click(function(){ - var email = $('#register_login').val(); - if (isValidEmailAddress(email)){ - $('.affiliate_loader').show(); - ajax.jsonRpc("/affiliate/join", 'call',{'email': email}).then(function (result){ - if (result){ + $("#later_button").click(function () { + $("#aff_req_btn").hide(); + }); + + $("[id^=yes_btn_uid_]").on("click", function () { + var uid = this.id.split("_")[3]; + ajax.jsonRpc("/affiliate/request", "call", { user_id: uid }).then(function (result) { console.log(result); - $(".aff_box").replaceWith( - ""); +
" + ); + } + }); + $(".affiliate_loader").hide(); + return false; + } else { + console.log("wrong email"); + alert("Invalid Email type"); + return false; } - }); - $('.affiliate_loader').hide(); - return false; - }else{ - console.log("wrong email"); - alert("Invalid Email type"); - return false; - } + }); - }); - - - $("#cpy_cde").click(function() { + $("#cpy_cde").click(function () { $("#usr_aff_code").select(); - $(this).text('copied'); - setTimeout(function() { - $("#cpy_cde").text('copy'); + $(this).text("copied"); + setTimeout(function () { + $("#cpy_cde").text("copy"); }, 2000); - document.execCommand('copy'); + document.execCommand("copy"); return false; }); - $("#cpy_url").click(function() { + $("#cpy_url").click(function () { $("#usr_aff_url").select(); - $(this).text('copied') - setTimeout(function() { - $("#cpy_url").text('copy'); + $(this).text("copied"); + setTimeout(function () { + $("#cpy_url").text("copy"); }, 2000); - document.execCommand('copy'); + document.execCommand("copy"); return false; }); + $("#url_anchor").click(function () { + $("#affiliate_url_inp").show(); + $("#affiliate_code_inp").hide(); + return false; + }); - $("#url_anchor").click(function(){ - $("#affiliate_url_inp").show(); - $("#affiliate_code_inp").hide(); - return false; + $("#code_anchor").click(function () { + $("#affiliate_url_inp").hide(); + $("#affiliate_code_inp").show(); + return false; + }); + + if ($(window).width() < 570) { + $("#cpy_url").removeClass("ms-2"); + $(".report_amount").removeClass("mt-5"); + $(".report_amount").removeClass("ms-2"); + $(".report_amount").addClass("ms-4"); + } else { + $("#cpy_url").addClass("ms-2"); + $(".report_amount").addClass("mt-5"); + $(".report_amount").removeClass("ms-4"); + $(".report_amount").addClass("ms-2"); + } }); - - - $("#code_anchor").click(function(){ - $("#affiliate_url_inp").hide(); - $("#affiliate_code_inp").show(); - return false; - }); - - if ($(window).width() < 570) { - $('#cpy_url').removeClass('ms-2'); - $('.report_amount').removeClass('mt-5'); - $('.report_amount').removeClass('ms-2'); - $('.report_amount').addClass('ms-4'); - } else { - $('#cpy_url').addClass('ms-2'); - $('.report_amount').addClass('mt-5'); - $('.report_amount').removeClass('ms-4'); - $('.report_amount').addClass('ms-2'); - } - -}); - }); diff --git a/odex25_donation/affiliate_management/views/about_template.xml b/odex25_donation/affiliate_management/views/about_template.xml index 2c809fc12..dcb19c3fe 100644 --- a/odex25_donation/affiliate_management/views/about_template.xml +++ b/odex25_donation/affiliate_management/views/about_template.xml @@ -6,27 +6,35 @@
-