diff --git a/sale_purchase_previous_product_cost/__init__.py b/sale_purchase_previous_product_cost/__init__.py new file mode 100644 index 000000000..a85ad2ea7 --- /dev/null +++ b/sale_purchase_previous_product_cost/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# 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 . +# +############################################################################## +import models + diff --git a/sale_purchase_previous_product_cost/__manifest__.py b/sale_purchase_previous_product_cost/__manifest__.py new file mode 100644 index 000000000..fae2cd9ec --- /dev/null +++ b/sale_purchase_previous_product_cost/__manifest__.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef(shereef@cybrosys.in) +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# 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 . +# +############################################################################## +{ + "name": "Previous Sale/Purchase Product Rates", + 'version': '10.0.1.0', + "summary": """Provide Product's Previous Sale & Purchase Price History for Partner.""", + "description": """Provide product's previous prices in product master.""", + "category": "Sales", + 'author': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'company': 'Cybrosys Techno Solutions', + "depends": ['sale', 'purchase'], + "data": ['views/sale_order_view.xml'], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/sale_purchase_previous_product_cost/models/__init__.py b/sale_purchase_previous_product_cost/models/__init__.py new file mode 100644 index 000000000..d9886e24a --- /dev/null +++ b/sale_purchase_previous_product_cost/models/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# 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 . +# +############################################################################## +import sale_order + diff --git a/sale_purchase_previous_product_cost/models/sale_order.py b/sale_purchase_previous_product_cost/models/sale_order.py new file mode 100644 index 000000000..7241b929f --- /dev/null +++ b/sale_purchase_previous_product_cost/models/sale_order.py @@ -0,0 +1,100 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# 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 . +# +############################################################################## +from odoo import models, api, fields +from odoo.exceptions import Warning + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + @api.onchange('product_id') + def set_partner(self): + for each in self: + print each.order_id.partner_id.id + if each.product_id: + each.product_id.write({'order_partner_id': each.order_id.partner_id.id}) + + sale_data = fields.Datetime(comodel_name='sale.order', string='Sale Date', + related='order_id.date_order', store=True) + + +class PurchaseOrderLine(models.Model): + _inherit = 'purchase.order.line' + + @api.onchange('product_id') + def set_partner(self): + for each in self: + print each.order_id.partner_id.id + if each.product_id: + each.product_id.write({'order_partner_id': each.order_id.partner_id.id}) + + purchase_data = fields.Datetime(comodel_name='purchase.order', string='Purchase Date', + related='order_id.date_order', store=True) + + +class ProductTemplate(models.Model): + _inherit = "product.product" + + order_partner_id = fields.Many2one('res.partner', string="Partner") + + @api.multi + def action_sale_product_prices(self): + rel_view_id = self.env.ref( + 'sale_purchase_previous_product_cost.last_sale_product_prices_view') + sale_lines = self.env['sale.order.line'].search([('product_id', '=', self.id), + ('order_partner_id', '=', self.order_partner_id.id)], + order='create_date DESC') + if not sale_lines: + raise Warning("No sales history found.!") + else: + return { + 'view_type': 'tree', + 'view_mode': 'tree', + 'res_model': 'sale.order.line', + 'views': [(rel_view_id.id, 'tree')], + 'view_id': False, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'domain': "[('id','in',[" + ','.join(map(str, sale_lines.ids)) + "])]", + } + + @api.multi + def action_purchase_product_prices(self): + rel_view_id = self.env.ref( + 'sale_purchase_previous_product_cost.last_sale_product_purchase_prices_view') + purchase_lines = self.env['purchase.order.line'].search([('product_id', '=', self.id), + ('partner_id', '=', self.order_partner_id.id)], + order='create_date DESC') + if not purchase_lines: + raise Warning("No purchase history found.!") + else: + return { + 'view_type': 'tree', + 'view_mode': 'tree', + 'res_model': 'purchase.order.line', + 'views': [(rel_view_id.id, 'tree')], + 'view_id': False, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'domain': "[('id','in',[" + ','.join(map(str, purchase_lines.ids)) + "])]", + } + + + diff --git a/sale_purchase_previous_product_cost/static/description/banner.jpg b/sale_purchase_previous_product_cost/static/description/banner.jpg new file mode 100644 index 000000000..e10c28799 Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/banner.jpg differ diff --git a/sale_purchase_previous_product_cost/static/description/cybro_logo.png b/sale_purchase_previous_product_cost/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/cybro_logo.png differ diff --git a/sale_purchase_previous_product_cost/static/description/icon.png b/sale_purchase_previous_product_cost/static/description/icon.png new file mode 100644 index 000000000..1b8ea4ebf Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/icon.png differ diff --git a/sale_purchase_previous_product_cost/static/description/index.html b/sale_purchase_previous_product_cost/static/description/index.html new file mode 100644 index 000000000..db799a6fa --- /dev/null +++ b/sale_purchase_previous_product_cost/static/description/index.html @@ -0,0 +1,130 @@ +
+
+

Previous Sale/Purchase Product Rates

+

...Provide Product's Previous Sale & Purchase Price History....

+

Cybrosys Technologies

+
+

Features:

+
    +
  •    Previous sale price history.
  • +
  •    Previous purchase price history.
  • +
  •    Provide product's previous prices in product page.
  • +
+
+
+
+ +
+
+
+

Overview

+

+ This module enables a view to see all previous sale/purchase product rates of selected customer. It will help you to manage + your orders according to these price history. You can see these option from sale/purchase form. +

+
+
+
+ +
+ +

Sale/Purchase Order Form

+
+
+
+ +
+
+
+
+ +
+
+
+

+ Select product & go to product form view +

+
+
+
+
+ +
+
+

Product Form

+
+
+
+ +
+
+
+

+ In product form you can see a new tab named "Previous Price History". In this tab 'Partner' + field already filled with the partner name which you are selected in sale/purchase form. + You have also an option to change this 'Partner'. +

+
+
+
+
+ +
+ +

Previous Price History

+
+
+
+ +
+
+
+

+ To see previous sale price history please click on the button name 'Previous Sale Rates'. +

+
+
+
+ +
+
+
+

+ To see previous purchase price history please click on the button name 'Previous Purchase Rates'. +

+
+
+
+
+ +
+

Need Any Help?

+ +
+ + + + + + diff --git a/sale_purchase_previous_product_cost/static/description/purchase.png b/sale_purchase_previous_product_cost/static/description/purchase.png new file mode 100644 index 000000000..d57a063ea Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/purchase.png differ diff --git a/sale_purchase_previous_product_cost/static/description/purchase_form.png b/sale_purchase_previous_product_cost/static/description/purchase_form.png new file mode 100644 index 000000000..97d5931e0 Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/purchase_form.png differ diff --git a/sale_purchase_previous_product_cost/static/description/sale.png b/sale_purchase_previous_product_cost/static/description/sale.png new file mode 100644 index 000000000..d6453ef45 Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/sale.png differ diff --git a/sale_purchase_previous_product_cost/static/description/sale_form.png b/sale_purchase_previous_product_cost/static/description/sale_form.png new file mode 100644 index 000000000..90be6cc8d Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/sale_form.png differ diff --git a/sale_purchase_previous_product_cost/static/description/wizard.png b/sale_purchase_previous_product_cost/static/description/wizard.png new file mode 100644 index 000000000..36a98a668 Binary files /dev/null and b/sale_purchase_previous_product_cost/static/description/wizard.png differ diff --git a/sale_purchase_previous_product_cost/views/sale_order_view.xml b/sale_purchase_previous_product_cost/views/sale_order_view.xml new file mode 100644 index 000000000..735f13e14 --- /dev/null +++ b/sale_purchase_previous_product_cost/views/sale_order_view.xml @@ -0,0 +1,64 @@ + + + + last.product.prices.view + sale.order.line + + + + + + + + + + + + + + + + last.product.purchase_prices.view + purchase.order.line + + + + + + + + + + + + + + + + product_extended.product.form.view + product.product + 3 + + + + + + + + + + + +