Skip to content

Instantly share code, notes, and snippets.

View ray-odoo's full-sized avatar
💭
Spreading purple around the world!

Ray Carnes ray-odoo

💭
Spreading purple around the world!
View GitHub Profile
for record in self:
if record.delivery_count > 0:
record['x_delivery_status'] = 'draft'
else:
global_done = False
for picking in record.picking_ids.sorted(key=lambda r: r.id):
local_done = False
if picking.state in ['waiting','confirmed']:
record['x_delivery_status'] = 'waiting'
if picking.state in ['assigned']:
@ray-odoo
ray-odoo / action.code
Last active January 11, 2021 00:57
Leverage Employee Skills when assigning Tasks in the Projects App
# https://www.odoo.com/forum/help-1/how-can-i-leverage-employee-skills-when-assigning-tasks-in-the-projects-app-181599
###### Offboard:
env['ir.ui.view'].search([('name','=','custom_ray_odoo')]).unlink()
env['ir.model.fields'].search([('name','=','x_employee_skill_ids')]).unlink()
###### Onboard:
# Schema
# Available variables:
# - env: Odoo Environment on which the action is triggered
# - model: Odoo Model of the record on which the action is triggered; is a void recordset
# - record: record on which the action is triggered; may be void
# - records: recordset of all records on which the action is triggered in multi-mode; may be void
# - time, datetime, dateutil, timezone: useful Python libraries
# - log: log(message, level='info'): logging function to record debug information in ir.logging table
# - UserError: Warning Exception to use with raise
# To return an action, assign: action = {...}
https://www.odoo.com/documentation/14.0/reference/orm.html#fields
# simple Char field
name = fields.Char(string="Name", required="True", readonly="False", invisible="False", help="The name field help string", )
# note that required, readonly and invisible might be better defined in the View where they can be controlled via attrs
# to set a default
default='' # the name of the value
for record in records:
if record.model == 'project.task':
task = env['project.task'].search([('id','=',record.res_id)])
new_body = "<dl><dt>Project: </dt><dd>%s</dd>" % task.project_id.display_name
new_body += "<dt>Customer: </dt><dd>%s</dd>" % task.partner_id.display_name
new_body += "<dt>Deadline: </dt><dd>%s</dd>" % (task.date_deadline and task.date_deadline or 'N/A')
record['body_html'] = record.body_html + new_body + "</dl>"
<?xml version="1.0"?>
<tree string="Forecasted Inventory" create="0" multi_edit="1" editable="top">
<field name="write_date"/>
<field name="write_uid"/>
<field name="origin" readonly="1"/>
<field name="picking_id" widget="one2many_button" readonly="1"/>
<field name="date"/>
<field name="x_step"/>
<field name="product_id" readonly="1"/>
<field name="product_packaging_id" optional="hide" groups="product.group_stock_packaging"/>
<!-- Note: the ID's of your Company records may not be 1 and 2, so adjust accordingly -->
<!-- Odoo 15 -->
<data inherit_id="web.layout">
<xpath expr="//body" position="inside">
<t t-if="request.httprequest.cookies.get('cids') and request.httprequest.cookies.get('cids')[0] == '1'">
<style>.o_main_navbar {background-color: #57596F!important;border-bottom: 0px;}</style></t>
<t t-if="request.httprequest.cookies.get('cids') and request.httprequest.cookies.get('cids')[0] == '2'">
<style>.o_main_navbar {background-color: #6B3C3C!important;border-bottom: 0px;}</style></t>
@ray-odoo
ray-odoo / gist:f363fb5037c9bf0b6c69e21fd27591b9
Created July 21, 2022 22:40
Landed Cost - bringing the label from the Vendor Bill over to a custom field on the Valuation Adjustment Line
# Example Vendor Bill
Track "Track", 100 units x $10 = $1,000
Train "Train", 250 units x $7 = $1,750
Design "for Track", 1 unit x $195
Freight "for the PO", 1 unit x $595
Overcharge "for Track", 100 units x price_unit
Overcharge, "for Train", 250 units x price_unit
# We want to know, for each LC, should it be applied to one product, or both
# After this we need to delete the lines where there isn't a match - no design on train, no track overchange on train, etc
network:
version: 2
ethernets:
enp0s3:
addresses: [192.168.1.202/24]