Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Invoice Stokc Move

Subscribe

Get notified when there's activity on this post

This question has been flagged
stockinvoicetransfer
1 Reply
3389 Views
Avatar
Mohamad Ali Chamas

def action_stock_move(self):
if not self.picking_type_id:
raise UserError(_("Please select a picking type"))

for order in self:
if not self.invoice_picking_id:
pick = {}
if self.picking_type_id.code == 'outgoing':
pick = {
'picking_type_id': self.picking_type_id.id,
'partner_id': self.partner_id.id,
'origin': self.name,
'location_dest_id': self.partner_id.property_stock_customer.id,
'location_id': self.picking_type_id.default_location_src_id.id,
'move_type': 'direct'
}
if self.picking_type_id.code == 'incoming':
pick = {
'picking_type_id': self.picking_type_id.id,
'partner_id': self.partner_id.id,
'origin': self.name,
'location_dest_id': self.picking_type_id.default_location_dest_id.id,
'location_id': self.partner_id.property_stock_supplier.id,
'move_type': 'direct'
}
picking = self.env['stock.picking'].create(pick)

if self.type in ['out_refund', 'in_refund']:
picking.type = 'out_invoice' if self.type == 'in_refund' else 'in_invoice'
else:
picking.type = self.type

self.invoice_picking_id = picking.id
self.picking_count = len(picking)

moves = order.invoice_line_ids.filtered(
lambda r: r.product_id.type in ['product', 'consu'])._create_stock_moves(picking)

# Modify the quantity field for refunds
if self.type == 'in_refund' or self.type == 'out_refund':
for move in moves:
for line in move.move_line_ids:
line.qty_done = line.product_qty

move_ids = moves._action_confirm()
move_ids._action_assign()

if picking.state == 'draft':
picking.action_confirm()

if picking.state != 'assigned':
picking.action_assign()

if picking.state != 'assigned':
raise UserError(
_("Could not reserve all requested products. Please use the \
'Mark as Todo' button to handle the reservation manually."))

for move in picking.move_lines.filtered(
lambda m: m.state not in ['done', 'cancel']):
for move_line in move.move_line_ids:
actual_qty_moved = move.product_uom_qty - move_line.qty_done
move_line.write({'qty_done': actual_qty_moved})

picking.action_done()


This is a function created by Cybrosys to make stock moves upon invoicing, I updated the code to automatic transfer when pressing the button. But, I need to do the following: When creating a vendor bill, the stock is increasing based on this function and this is correct. But, when doing a refund I need to create a direct decrease in stock as if I am creating a customer invoice. How to do this based on this function?

0
Avatar
Discard
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

Here you have make an adjustment in the code in which you create the picking, if it is a vendor refund, you have to change the picking_type_id and swap the values of location_id and location_dest_id.


You can make the above changes by adding a if condition to check whether it is a vendor bill or vendor refund.


Thanks

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Accounting Invoice doesn't alter stock in hand Solved
stock invoice
Avatar
Avatar
1
Dec 22
8251
create invoice for transporter
stock transfer
Avatar
0
Dec 15
3867
How to transfer a value from order to invoice
invoice order transfer
Avatar
Avatar
1
May 16
4954
Massively transfer all stock from location A to location B Solved
stock inventory locations transfer
Avatar
Avatar
Avatar
Avatar
4
May 24
4758
How can i make supplier invoice with stock entry in POS ?
stock invoice supplier input
Avatar
Avatar
1
Aug 23
5201
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now