Browse Source

[ADD] Initial Commit

pull/94/head
Sreejith P 7 years ago
parent
commit
390bc3e8db
  1. 48
      sale_promotion/README.rst
  2. 27
      sale_promotion/__init__.py
  3. 47
      sale_promotion/__manifest__.py
  4. 29
      sale_promotion/models/__init__.py
  5. 33
      sale_promotion/models/promotion_product.py
  6. 181
      sale_promotion/models/sale_order.py
  7. 81
      sale_promotion/models/sale_promotion_rule.py
  8. 7
      sale_promotion/security/ir.model.access.csv
  9. BIN
      sale_promotion/static/description/banner.jpg
  10. BIN
      sale_promotion/static/description/cybro_logo.png
  11. BIN
      sale_promotion/static/description/icon.png
  12. 122
      sale_promotion/static/description/index.html
  13. BIN
      sale_promotion/static/description/promo1.png
  14. BIN
      sale_promotion/static/description/promo2.png
  15. BIN
      sale_promotion/static/description/promo3.png
  16. BIN
      sale_promotion/static/description/promo4.png
  17. BIN
      sale_promotion/static/description/sale.png
  18. 18
      sale_promotion/views/promotion_product.xml
  19. 23
      sale_promotion/views/sale_order.xml
  20. 129
      sale_promotion/views/sale_promotion_rule.xml

48
sale_promotion/README.rst

@ -0,0 +1,48 @@
==================
Sale Promotion v11
==================
Add option to give promotion for your products.
Contacts
========
* Cybrosys Techno Solutions <https://www.cybrosys.com>
Depends
=======
[sale] addon Odoo
[account_invoicing] addon Odoo
Tech
====
* [Python] - Models
* [XML] - Odoo views
Installation
============
- www.odoo.com/documentation/11.0/setup/install.html
- Install our custom addon
License
=======
GNU Affero General Public License
(http://www.gnu.org/licenses/agpl.html)
Bug Tracker
===========
Contact odoo@cybrosys.com
Authors
-------
* Developer v10: Anusha @ Cybrosys, anusha@cybrosys.in
* Developer v11: Niyas Raphy @ Cybrosys, niyas@cybrosys.in
Maintainer
----------
This module is maintained by Cybrosys Technologies.
For support and more information, please visit https://www.cybrosys.com.

27
sale_promotion/__init__.py

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Anusha P P(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
from . import models

47
sale_promotion/__manifest__.py

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Anusha P P(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
{
'name': "Sale Promotion",
'version': '11.0.1.0.0',
'summary': """Create Promotion Offers For Sales""",
'description': """This Module Allows to Set Promotion Offers On Products And Product Categories.""",
'author': "Cybrosys Techno Solutions",
'maintainer': 'Cybrosys Techno Solutions',
'company': "Cybrosys Techno Solutions",
'website': "https://www.cybrosys.com",
'category': 'Sales',
'depends': ['sale', 'account_invoicing'],
'data': [
'security/ir.model.access.csv',
'views/promotion_product.xml',
'views/sale_promotion_rule.xml',
'views/sale_order.xml',
],
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',
'installable': True,
'auto_install': False,
}

29
sale_promotion/models/__init__.py

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Anusha P P(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
from . import promotion_product
from . import sale_promotion_rule
from . import sale_order

33
sale_promotion/models/promotion_product.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Anusha P P(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import models, fields
class PromotionProduct(models.Model):
_inherit = 'product.template'
is_promotion_product = fields.Boolean(string="Promotion Product", default=False,help='This is a promotion product')

181
sale_promotion/models/sale_order.py

@ -0,0 +1,181 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Anusha P P(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
from dateutil import parser
from odoo import models, fields, api, _
from odoo.exceptions import UserError
class SalePromotion(models.Model):
_inherit = 'sale.order'
sale_promotion_id = fields.Many2one('sale.promotion', string="Sale Promotion")
@api.multi
def button_dump_sale_promotion(self):
for order in self:
if order.sale_promotion_id:
date_order = parser.parse(order.date_order).strftime('%Y-%m-%d')
product_list = []
category_list = []
for line in order.order_line:
count = 0
categ_count = 0
if line.is_promotion_line:
line.unlink()
else:
if product_list:
for data in product_list:
if data['product_id'] == line.product_id.id:
data['qty'] += line.product_uom_qty
count += 1
if count == 0:
product_list.append({
'product_id': line.product_id.id,
'qty': line.product_uom_qty,
})
else:
product_list.append({
'product_id': line.product_id.id,
'qty': line.product_uom_qty,
})
if category_list:
for prod in category_list:
if prod['category'] == line.product_id.categ_id.id:
prod['qty'] += line.product_uom_qty
categ_count += 1
if categ_count == 0:
category_list.append({
'qty': line.product_uom_qty,
'category': line.product_id.categ_id.id,
})
else:
category_list.append({
'qty': line.product_uom_qty,
'category': line.product_id.categ_id.id,
})
category_rule_ids = []
product_rule_ids = []
for obj in self.sale_promotion_id:
for promo_lines in obj.item_ids:
if not promo_lines.date_start or promo_lines.date_start <= date_order:
if not promo_lines.date_end or promo_lines.date_end >= date_order:
if promo_lines.applied_on == 'product_category':
categ_val = {'rule': promo_lines,
'category': promo_lines.categ_id.id,
'qty': promo_lines.min_quantity,
}
category_rule_ids.append(categ_val)
elif promo_lines.applied_on == 'product':
pr_val = {'rule': promo_lines,
'product_id': promo_lines.product_tmpl_id.id,
'qty': promo_lines.min_quantity,
}
product_rule_ids.append(pr_val)
sale_line_obj = self.env['sale.order.line']
if product_rule_ids and product_list:
for data in product_list:
rules = []
for i in product_rule_ids:
if i['product_id'] == data['product_id']:
if data['qty'] >= i['rule'].min_quantity:
rules.append(i)
if len(rules) > 1:
max_qty_rule = max(rules, key=lambda x: x['qty'])
for line in max_qty_rule['rule'].promotion_rule_lines:
sale_line_obj.create({
'name': line.product_id.name,
'price_unit': 0,
'product_uom_qty': line.quantity,
'order_id': order.id,
'discount': 0.0,
'product_uom': line.product_id.uom_id.id,
'product_id': line.product_id.id,
'tax_id': [],
'is_promotion_line': True,
})
elif len(rules) == 1:
for r in rules:
for line in r['rule'].promotion_rule_lines:
sale_line_obj.create({
'name': line.product_id.name,
'price_unit': 0,
'product_uom_qty': line.quantity,
'order_id': order.id,
'discount': 0.0,
'product_uom': line.product_id.uom_id.id,
'product_id': line.product_id.id,
'tax_id': [],
'is_promotion_line': True,
})
else:
pass
if category_rule_ids and category_list:
for categ in category_list:
rules = []
for r in category_rule_ids:
if categ['category'] == r['category']:
if categ['qty'] >= r['rule'].min_quantity:
rules.append(r)
if len(rules) > 1:
max_qty_rule = max(rules, key=lambda x: x['qty'])
for line in max_qty_rule['rule'].promotion_rule_lines:
sale_line_obj.create({
'name': line.product_id.name,
'price_unit': 0,
'product_uom_qty': line.quantity,
'order_id': order.id,
'discount': 0.0,
'product_uom': line.product_id.uom_id.id,
'product_id': line.product_id.id,
'tax_id': [],
'is_promotion_line': True,
})
elif len(rules) == 1:
for r in rules:
for line in r['rule'].promotion_rule_lines:
sale_line_obj.create({
'name': line.product_id.name,
'price_unit': 0,
'product_uom_qty': line.quantity,
'order_id': order.id,
'discount': 0.0,
'product_uom': line.product_id.uom_id.id,
'product_id': line.product_id.id,
'tax_id': [],
'is_promotion_line': True,
})
else:
pass
else:
raise UserError(_('Please Select an Promotion Rule.'))
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
is_promotion_line = fields.Boolean(string='Promotion Line')

81
sale_promotion/models/sale_promotion_rule.py

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Anusha P P(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################
from odoo.exceptions import UserError
from odoo import models, fields, _, api
class SalePromotion(models.Model):
_name = 'sale.promotion'
def _get_default_currency_id(self):
return self.env.user.company_id.currency_id.id
name = fields.Char(string="Name", required=True)
item_ids = fields.One2many('sale.promotion.rule', 'promotion_id', string="Promotion Rules")
company_id = fields.Many2one('res.company')
currency_id = fields.Many2one('res.currency')
class SalePromotionRule(models.Model):
_name = 'sale.promotion.rule'
name = fields.Char(string="Name", required=True)
promotion_id = fields.Many2one('sale.promotion', string="Promotion Rule")
applied_on = fields.Selection([('product_category', 'Product Category'),
('product', 'Product')], string="Applied On", default='product', required=True)
min_quantity = fields.Integer(string="Minimum Quantity")
date_start = fields.Date(string="Date Start")
date_end = fields.Date(string="Date End")
categ_id = fields.Many2one('product.category', string="Product Category")
product_tmpl_id = fields.Many2one('product.product', string="Product")
company_id = fields.Many2one('res.company', string='Company', readonly=True, related='promotion_id.company_id', store=True)
currency_id = fields.Many2one('res.currency', string='Currency',
readonly=True, related='promotion_id.currency_id', store=True)
promotion_rule_lines = fields.One2many('sale.promotion.rule.line', 'promotion_rule_id', string="Promotion Lines")
@api.constrains('date_start', 'date_end')
def check_date(self):
if self.date_start and self.date_end:
if self.date_end < self.date_start:
raise UserError(_('Please check the Ending date.'))
@api.constrains('promotion_rule_lines')
def check_promotion(self):
if not self.promotion_rule_lines:
raise UserError(_('Please Add some promotion products.'))
class SalePromotionLines(models.Model):
_name = 'sale.promotion.rule.line'
product_id = fields.Many2one('product.product', string="Product")
quantity = fields.Integer(string="Quantity")
promotion_rule_id = fields.Many2one('sale.promotion.rule', string="Promotion Lines")

7
sale_promotion/security/ir.model.access.csv

@ -0,0 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_promotion_manager,sale.promotion,model_sale_promotion,sales_team.group_sale_manager,1,1,1,1
access_sale_promotion_salesman,sale.promotion,model_sale_promotion,sales_team.group_sale_salesman,1,1,1,1
access_sale_promotion_rule_manager,sale.promotion.rule,model_sale_promotion_rule,sales_team.group_sale_manager,1,1,1,1
access_sale_promotion_rule_salesman,sale.promotion.rule,model_sale_promotion_rule,sales_team.group_sale_salesman,1,1,1,1
access_sale_promotion_rule_line_manager,sale.promotion.rule.line,model_sale_promotion_rule_line,sales_team.group_sale_manager,1,1,1,1
access_sale_promotion_rule_line_salesman,sale.promotion.rule.line,model_sale_promotion_rule_line,sales_team.group_sale_salesman,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sale_promotion_manager sale.promotion model_sale_promotion sales_team.group_sale_manager 1 1 1 1
3 access_sale_promotion_salesman sale.promotion model_sale_promotion sales_team.group_sale_salesman 1 1 1 1
4 access_sale_promotion_rule_manager sale.promotion.rule model_sale_promotion_rule sales_team.group_sale_manager 1 1 1 1
5 access_sale_promotion_rule_salesman sale.promotion.rule model_sale_promotion_rule sales_team.group_sale_salesman 1 1 1 1
6 access_sale_promotion_rule_line_manager sale.promotion.rule.line model_sale_promotion_rule_line sales_team.group_sale_manager 1 1 1 1
7 access_sale_promotion_rule_line_salesman sale.promotion.rule.line model_sale_promotion_rule_line sales_team.group_sale_salesman 1 1 1 1

BIN
sale_promotion/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
sale_promotion/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
sale_promotion/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

122
sale_promotion/static/description/index.html

@ -0,0 +1,122 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Sale Promotion</h2>
<h3 class="oe_slogan">Set sales promotion offers on product and product categories.</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4>
</div>
<div class="oe_row oe_spaced">
<h4><p style="margin-left: 42px;">Major Features:</p></h4>
<ul>
<li style="list-style:none !important;"><span style="color:green;"> &#9733;</span>&nbsp;&nbsp; Create sales promotion offers for products.</li>
<li style="list-style:none !important;"><span style="color:green;"> &#9733;</span>&nbsp;&nbsp; Create sales promotion offers for product categories.</li>
<li style="list-style:none !important;"><span style="color:green;"> &#9733;</span>&nbsp;&nbsp; Attract more customers.</li>
</ul>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32 text-justify" style="text-align: center;">
The module, allows the user to set sales promotion offers on products and product category.
Create product and Product category based specific promotion rules and improve the sales.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div style="text-align: center">
<p>
<h3>Create Promotion Rules</h3>
</p>
</div>
</div>
<div class="oe_row oe_spaced">
<div class="" style="text-align: center">
<span class="oe_mt32 text-justify" style="text-align: center;">Case 1.Buy One get One Free.</span>
</div>
</div>
<div>
<div class="" style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="promo1.png">
</div>
</div>
<div class="" style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="promo2.png">
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="" style="text-align: center">
<span class="oe_mt32 text-justify" style="text-align: center;">Case 2.Buy 2 Get Another Free</span>
</div>
</div>
<div class="oe_row oe_spaced">
<div class="" style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="promo3.png">
</div>
</div>
<div class="" style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="promo4.png">
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div style="text-align: center">
<p>
<h3>Select Offer In Sale Order</h3>
</p>
</div>
<div class="" style="text-align: center">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="sale.png">
</div>
<span class="oe_mt32 text-justify" style="text-align: center;">Select the promotion rule in the sale order and click on 'Apply Offer'</span>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

BIN
sale_promotion/static/description/promo1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
sale_promotion/static/description/promo2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
sale_promotion/static/description/promo3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
sale_promotion/static/description/promo4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
sale_promotion/static/description/sale.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

18
sale_promotion/views/promotion_product.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="product_template_form_view_inherit" model="ir.ui.view">
<field name="name">product.template</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='type']" position="before">
<field name="is_promotion_product"/>
</xpath>
</field>
</record>
</data>
</odoo>

23
sale_promotion/views/sale_order.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!--showing promotion list in sale order form-->
<record id="sale_promotion_in_sale_order_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='print_quotation']" position="after">
<button name="button_dump_sale_promotion" class="btn-primary"
string="Apply offer" states="draft,sent" type="object" context="{'show_sale': True}"/>
</xpath>
<xpath expr="//field[@name='pricelist_id']" position="after">
<field name="sale_promotion_id"/>
</xpath>
<xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='name']" position="after">
<field name="is_promotion_line" invisible="1"/>
</xpath>
</field>
</record>
</data>
</odoo>

129
sale_promotion/views/sale_promotion_rule.xml

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<!--Sale promotion rule view-->
<record id="sale_promotion_rule_tree_view" model="ir.ui.view">
<field name="name">sale.promotion.rule.tree</field>
<field name="model">sale.promotion.rule</field>
<field name="arch" type="xml">
<tree string="Sale Promotion Rules">
<field colspan="4" name="name"/>
<field name="product_tmpl_id"/>
<field name="categ_id"/>
<field name="min_quantity"/>
<field name="date_start"/>
<field name="date_end"/>
</tree>
</field>
</record>
<record id="sale_promotion_rule_form_view" model="ir.ui.view">
<field name="name">sale.promotion.rule.form</field>
<field name="model">sale.promotion.rule</field>
<field name="arch" type="xml">
<form string="Sale Promotion Rule">
<h1><field name="name"/></h1>
<group>
<group>
<field name="applied_on" widget="radio"/>
<field name="categ_id" attrs="{'invisible':[('applied_on', '!=', 'product_category')], 'required':[('applied_on', '=', 'product_category')]}"/>
<field name="product_tmpl_id"
attrs="{'invisible':[('applied_on', '!=', 'product')],'required':[('applied_on', '=', 'product')]}" string="Product"/>
</group>
<group>
<field name="min_quantity"/>
<field name="date_start"/>
<field name="date_end"/>
</group>
</group>
<notebook>
<page string="Promotion Rule lines">
<field name="promotion_rule_lines">
<tree name="Promotion Rule Lines">
<field name="product_id" domain="[('is_promotion_product','=',True),('sale_ok', '=', True)]"/>
<field name="quantity"/>
</tree>
</field>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="sale_promotion_view_search">
<field name="name">sale.promotion.search</field>
<field name="model">sale.promotion</field>
<field name="arch" type="xml">
<search string="Sale Promotion Search">
<field name="name" string="Promotion"/>
</search>
</field>
</record>
<record id="sale_promotion_view_tree" model="ir.ui.view">
<field name="name">sale.promotion.tree</field>
<field name="model">sale.promotion</field>
<field name="arch" type="xml">
<tree string="Sale promotion">
<field name="name"/>
</tree>
</field>
</record>
<record id="sale_promotion_view_form" model="ir.ui.view">
<field name="name">sale.promotion.form</field>
<field name="model">sale.promotion</field>
<field name="arch" type="xml">
<form string="Sale Promotion">
<sheet>
<div class="oe_title">
<h1><field name="name" placeholder="e.g.Buy 1 get 1 free"/></h1>
</div>
<div>
<separator string="Sale Promotion Rules"/>
<field name="item_ids" nolabel="1">
<tree string="Sale Promotion Rules">
<field name="name" string="Applicable On"/>
<field name="min_quantity"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="applied_on" invisible="1"/>
</tree>
</field>
</div>
</sheet>
</form>
</field>
</record>
<record id="action_sale_promotion_menu" model="ir.actions.act_window">
<field name="name">Sale Promotions</field>
<field name="res_model">sale.promotion</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!--sale promotion rule lines form view-->
<record id="sale_promotion_rule_lines_form_view" model="ir.ui.view">
<field name="name">sale.promotion.rule.line.form</field>
<field name="model">sale.promotion.rule.line</field>
<field name="arch" type="xml">
<form string="Sale Promotion Rule">
<group>
<group>
<field name="product_id" domain="[('is_promotion_product','=',True),('sale_ok', '=', True)]" options="{'no_create': True}"/>
<field name="quantity"/>
</group>
</group>
</form>
</field>
</record>
<menuitem name="Sale Promotions" id="sale_promotion_menu"
parent="sale.menu_sale_config" sequence="3" />
<menuitem name="Sale Promotions" id="sale_promotion_child_menu" action="action_sale_promotion_menu"
parent="sale_promotion_menu" sequence="3" />
</data>
</odoo>
Loading…
Cancel
Save