Browse Source

[ADD] Initial Commit

pull/45/head
SHEREEF PT 7 years ago
parent
commit
133e60487d
  1. 23
      picking_create_invoice/__init__.py
  2. 43
      picking_create_invoice/__manifest__.py
  3. 23
      picking_create_invoice/models/__init__.py
  4. 157
      picking_create_invoice/models/delivery_invoice.py
  5. BIN
      picking_create_invoice/static/description/banner.jpg
  6. BIN
      picking_create_invoice/static/description/cus.png
  7. BIN
      picking_create_invoice/static/description/cybro_logo.png
  8. BIN
      picking_create_invoice/static/description/icon.png
  9. 145
      picking_create_invoice/static/description/index.html
  10. BIN
      picking_create_invoice/static/description/so1.png
  11. BIN
      picking_create_invoice/static/description/so2.png
  12. BIN
      picking_create_invoice/static/description/wh1.png
  13. BIN
      picking_create_invoice/static/description/wh2.png
  14. 17
      picking_create_invoice/views/customer_picking.xml
  15. 57
      picking_create_invoice/views/invoice_option_view.xml

23
picking_create_invoice/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria(<https://www.cybrosys.com>)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) 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 <https://www.gnu.org/licenses/>.
#
###################################################################################
import models

43
picking_create_invoice/__manifest__.py

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria(<https://www.cybrosys.com>)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) 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 <https://www.gnu.org/licenses/>.
#
###################################################################################
{
'name': 'Extended Scope For Invoicing Policy',
'version': '10.0.1.0.0',
'summary': 'Set Your Invoicing Policy at Different Levels',
'description': 'Invoicing policy is implemented in sale orders as well as customer side',
'category': 'Sales',
'author': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com",
'company': 'Cybrosys Techno Solutions',
'depends': ['base', 'sale', 'stock', 'account'],
'data': [
'views/invoice_option_view.xml',
'views/customer_picking.xml',
],
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',
'installable': True,
'auto_install': False,
'application': False,
}

23
picking_create_invoice/models/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria(<https://www.cybrosys.com>)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) 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 <https://www.gnu.org/licenses/>.
#
###################################################################################
import delivery_invoice

157
picking_create_invoice/models/delivery_invoice.py

@ -0,0 +1,157 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria(<https://www.cybrosys.com>)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) 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 <https://www.gnu.org/licenses/>.
#
###################################################################################
from odoo.exceptions import UserError
from odoo import fields, models, api, _
from odoo.tools import float_is_zero
class CustomerInvoice(models.Model):
_inherit = 'res.partner'
invoice_option = fields.Selection([('on_delivery', 'Delivered quantities'),
('before_delivery', 'Ordered quantities'), ],
"Invoicing Policy")
class DeliveryInvoice(models.Model):
_inherit = 'sale.order'
invoice_option = fields.Selection([('on_delivery', 'Delivered quantities'),
('before_delivery', 'Ordered quantities'), ],
string="Invoicing Policy")
@api.onchange('partner_id')
def onchange_customer(self):
if self.partner_id.invoice_option:
self.invoice_option = self.partner_id.invoice_option
else:
self.invoice_option = False
@api.multi
def action_invoice_create(self, grouped=False, final=False):
"""
Create the invoice associated to the SO.
:param grouped: if True, invoices are grouped by SO id. If False, invoices are grouped by
(partner_invoice_id, currency)
:param final: if True, refunds will be generated if necessary
:returns: list of created invoices
"""
if self.invoice_option == 'before_delivery':
inv_obj = self.env['account.invoice']
for order in self:
inv_data = order._prepare_invoice()
invoice = inv_obj.create(inv_data)
for inv_line in order.order_line:
inv_line.invoice_line_create(invoice.id, inv_line.product_uom_qty)
else:
inv_obj = self.env['account.invoice']
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
invoices = {}
references = {}
for order in self:
group_key = order.id if grouped else (order.partner_invoice_id.id, order.currency_id.id)
for line in order.order_line.sorted(key=lambda l: l.qty_to_invoice < 0):
if float_is_zero(line.qty_to_invoice, precision_digits=precision):
continue
if group_key not in invoices:
inv_data = order._prepare_invoice()
invoice = inv_obj.create(inv_data)
references[invoice] = order
invoices[group_key] = invoice
elif group_key in invoices:
vals = {}
if order.name not in invoices[group_key].origin.split(', '):
vals['origin'] = invoices[group_key].origin + ', ' + order.name
if order.client_order_ref and order.client_order_ref \
not in invoices[group_key].name.split(', '):
vals['name'] = invoices[group_key].name + ', ' + order.client_order_ref
invoices[group_key].write(vals)
if line.qty_to_invoice > 0:
line.invoice_line_create(invoices[group_key].id, line.qty_to_invoice)
elif line.qty_to_invoice < 0 and final:
line.invoice_line_create(invoices[group_key].id, line.qty_to_invoice)
if references.get(invoices.get(group_key)):
if order not in references[invoices[group_key]]:
references[invoice] = references[invoice] | order
if not invoices:
raise UserError(_('There is no invoicable line.'))
for invoice in invoices.values():
if not invoice.invoice_line_ids:
raise UserError(_('There is no invoicable line.'))
# If invoice is negative, do a refund invoice instead
if invoice.amount_untaxed < 0:
invoice.type = 'out_refund'
for line in invoice.invoice_line_ids:
line.quantity = -line.quantity
for line in invoice.invoice_line_ids:
line._set_additional_fields(invoice)
invoice.compute_taxes()
invoice.message_post_with_view('mail.message_origin_link',
values={'self': invoice, 'origin': references[invoice]},
subtype_id=self.env.ref('mail.mt_note').id)
return [inv.id for inv in invoices.values()]
class InvoiceControl(models.Model):
_inherit = 'stock.picking'
invoice_control = fields.Selection([('to_invoice', 'To be Invoiced'),
('invoice_na', 'Not applicable'), ],
string="Invoicing Policy", compute='get_invoice_control')
@api.depends('group_id')
def get_invoice_control(self):
for group in self:
obj = self.env['sale.order'].search([('name', '=', group.group_id.name)])
if obj.invoice_option == 'on_delivery':
group.invoice_control = 'to_invoice'
elif obj.invoice_option == 'before_delivery':
group.invoice_control = 'invoice_na'
else:
group.invoice_control = False
@api.depends('group_id')
def pick_create_invoices(self):
sale_orders = self.env['sale.order'].search([('name', '=', self.group_id.name)])
sale_orders.action_invoice_create()
return sale_orders.action_view_invoice()

BIN
picking_create_invoice/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
picking_create_invoice/static/description/cus.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
picking_create_invoice/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
picking_create_invoice/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

145
picking_create_invoice/static/description/index.html

@ -0,0 +1,145 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Extended Scope For Invoicing Policy</h2>
<h3 class="oe_slogan">Set Your Invoicing Policy at Different Levels</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4>
</div>
<div class="oe_row oe_spaced" style="padding-left:65px;">
<h4>Features:</h4>
<div>
<span style="color:green;"> &#9745; </span> Invoicing policy in sale order.<br/>
<span style="color:green;"> &#9745; </span> Invoicing policy in customers.<br/>
<span style="color:green;"> &#9745; </span> Prioritized level.<br/>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h2 class="oe_slogan">Overview</h2>
<p class="oe_mt32">
Generally, we can choose the invoice creation process in two ways:
<ul>
<li>&nbsp;Ordered quantities : Before processing the delivery</li>
<li> Delivered quantities : After finishing the delivery process</li>
</ul>
Currently, in Odoo, we can set this feature only on the product side. This module extends the
scope of this feature to Sale Orders as well as Customers. Then, the priority of Invoicing
Policy will be as follows.
<h4>Sale Order > Customer side > Product side > Default Settings</h4>
<p>That is, Invoicing Policy set in Sale Order will get the high priority and
Default settings will be considered only if the rest of the levels doesn't
contain any Invoicing Policies.</p>
</div>
</div>
</section>
<section class="oe_container ">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Invoicing Policy in Sale Order: Delivered quantities</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p>First, you have to download and Install the application form
Odoo App Store. Then follow the below steps to enable the feature.</p>
<p><ul>
<li> Create a Sale Order.</li>
<li> Go to Other Information ->Create Invoice -> Set 'Delivered quantities'</li>
<li> You can create invoice only after the delivery of the product.
'Create Invoice' will not be visible on sale order</li>
</ul>
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="so2.png">
</div>
<p><ul>
<li> At the Delivery side, create invoice will be 'To be Invoiced, which
indicates the invoice can be created from the picking side. When the
delivery is done, you can create the invoice from the delivery order itself.</li>
</ul>
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="wh2.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Invoicing Policy in Sale Order : Ordered quantities</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p><ul>
<li> Create a Sale Order.</li>
<li> Go to Other Information ->Create Invoice -> Set 'Ordered quantities'</li>
<li> After confirming the sale orders, you can directly create the invoice
from sale order itself.</li>
</ul>
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="so1.png">
</div>
<p><ul>
<li>At Delivery side, create invoice will be 'Not Applicable', which
indicates invoice cannot be created from the picking side.</li>
</ul>
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="wh1.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container ">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Invoicing policy in Customer Side</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p></p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="cus.png">
</div>
</div>
</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
picking_create_invoice/static/description/so1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

BIN
picking_create_invoice/static/description/so2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

BIN
picking_create_invoice/static/description/wh1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
picking_create_invoice/static/description/wh2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

17
picking_create_invoice/views/customer_picking.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="customer_invoice_option_view">
<field name="name">customer.invoice.option.view</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='purchase']" position="after">
<group string="Invoicing Policy">
<field name="invoice_option"/></group>
</xpath>
</field>
</record>
</data>
</odoo>

57
picking_create_invoice/views/invoice_option_view.xml

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="invoice_option_view">
<field name="name">invoice.option.view</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='sales_person']" position="inside">
<field name="invoice_option"/>
</xpath>
<xpath expr="//button[1]" position="replace">
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"
type="action" class="btn-primary"
attrs="{'invisible': ['|',('invoice_option','=','on_delivery'),('invoice_status', '!=', 'to invoice'),]}"/>
</xpath>
<xpath expr="//button[2]" position="replace" >
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"
type="action" context="{'default_advance_payment_method': 'percentage'}"
attrs="{'invisible': ['|','|',('invoice_option','=','on_delivery'),('invoice_status', '!=', 'no'),('state', '!=', 'sale')]}"/>
</xpath>
</field></record>
<record model="ir.ui.view" id="invoice_control_view">
<field name="name">invoice.control.view</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//header/button[1]" position="before" >
<button name="pick_create_invoices" string="Create Invoice"
type="object" class="btn-primary"
attrs="{'invisible': ['|',('invoice_control','!=','to_invoice'),
('state','!=','done'),]}"/>
</xpath>
<xpath expr="//page[@name='extra']/group/group/field[@name='group_id']" position="after">
<field name="invoice_control"/>
</xpath>
</field></record>
<!--<record id="action_view_sale_advance_payment_inv_2" model="ir.actions.act_window">-->
<!--<field name="name">Invoice Order</field>-->
<!--<field name="type">ir.actions.act_window</field>-->
<!--<field name="res_model">sale.advance.payment.inv</field>-->
<!--<field name="view_type">form</field>-->
<!--<field name="view_mode">form</field>-->
<!--<field name="target">new</field>-->
<!--<field name="groups_id" eval="[(4,ref('sales_team.group_sale_salesman'))]"/>-->
<!--</record>-->
</data>
</odoo>
Loading…
Cancel
Save