Wednesday, August 12, 2020

Odoo 13

Setup Odoo 13 through Docker

use Docker compose found on 
https://github.com/minhng92/odoo-13-docker-compose

it will start Postgres DB and Odoo servers.
to connect to DB
1) docker ps
2) get container ID related to DB instance
3) docker exec -it <Container ID> bash

Inside docker instance write command:
psql -U odoo -W

To View Available Databases 
SELECT datname FROM pg_database;

To Enable Odoo Developer Mode














Notes:
debug with assets will use actual css and javascript files instead of minifying/merging css and js files. This mode will reduce performance but it will give you proper error message in console if you are doing some JavaScript changes in odoo.
 

How to add new field to exist form, for example Add new field to Sales module\ product Form ?
1) Enable Developer mode
2) Install Sales module, Navigate to that product form
3) Click on "Open Developer Tool"

 




4) choose "Edit View:Form"























































5) Settings > Technical > Database Structure > Models 
6) Search for the model that exists on edit view "product.template"



7) Add Field with label "Weight" and Name "x_Weight",
     Note that, the custom field should start with "x_"
8) Navigate back to form "Sales\Add Product" and from developer mode menu choose "Edit View:Form" and add the new column   <field name="x_Weight" />



9) Refresh form add view to validate exists of the new feild







How to add this new field to the Products Grid official name is "View List" ?



1) Choose View List
2) From Developer Debug menu choose "Edit View: List"
3) Add new Column   <field name="x_Weight" />


























4) Validate Grid after add the new Tag






How to control Odoo Top Menus? 
Settings > Technical > Menu Items

For Example, How to configure Sales menu,?



1) Go to  Settings > Technical > Menu Items then search for Sales



2) Click on Sales then choose "Sub Menus"


3) Change Menu order or items text or add new menu item

Thursday, August 6, 2020

flutter

How to clear Flutter's Build cache?
run the next command on project folder 
flutter clean .


How to Call StatelessWidget with parameter ?

//MainBody(1); call MainBody and pass 1 to the class

class MainBody extends StatelessWidget {
  MainBody(this.yourData);

  final int yourData;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Padding(
        padding: const EdgeInsets.only(left: 20.0, right: 20.0),
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new TimeCheck(yourData),
          ],
        ),
      ),
    );
  }
}


How to Call StatefulWidget with parameter?

//MyHomePage(title: 'MBRF Home Page');

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ));
    
  }
}





SAMPLE Code

import 'package:flutter/material.dart';

void main(){



  runApp(MaterialApp(
    title: "Demo App",
    routes: {
      HomePage.routeName : (_) => HomePage(),
      Step1Page.routeName : (_) => Step1Page(),
      Step2Page.routeName : (_) => Step2Page(),
      Step3Page.routeName : (_) => Step3Page(),
    },
    home: SplashPage(),
    initialRoute: HomePage.routeName,
  ));
}

class SplashPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold();
  }
}


class HomePage extends StatelessWidget {

  static const routeName = "/home";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("Home Page"),
            RaisedButton(onPressed: (){
              Navigator.pushNamed(context, Step1Page.routeName);
            }, child: Text("Start Steps"),)
          ],
        ),
      ),
    );
  }
}


class Step1Page extends StatelessWidget {

  static const routeName = "/step1";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("Step1 Page"),
            RaisedButton(onPressed: (){
              Navigator.pushNamed(context, Step2Page.routeName);
            }, child: Text("Go Step2"),)
          ],
        ),
      ),
    );
  }
}



class Step2Page extends StatelessWidget {

  static const routeName = "/step2";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("Step2 Page"),
            RaisedButton(onPressed: (){
              Navigator.pushNamed(context, Step3Page.routeName);
            }, child: Text("Go Step3"),)
          ],
        ),
      ),
    );
  }
}

class Step3Page extends StatelessWidget {

  static const routeName = "/step3";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("Step3 Page"),
            RaisedButton(onPressed: (){
              Navigator.popUntil(context, (Route<dynamic> route){
                bool shouldPop = false;
                if(route.settings.name == HomePage.routeName){
                  shouldPop = true;
                }
                return shouldPop;
              });
            }, child: Text("Go Home"),)
          ],
        ),
      ),
    );
  }
}
















Dialog


showDialog<bool>(
  context: context,
  builder: (c) => AlertDialog(
    title: Text('Warning'),
    content: Text('Do you want to register on new conference?'),
    actions: [
      FlatButton(
        child: Text('Yes'),
        onPressed: () =>   Navigator.popUntil(context, (Route<dynamic> route){
          bool shouldPop = false;
          print(route.settings.name);
          if(route.settings.name == "RegisterConfranceForm"){
            shouldPop = true;
          }
          return shouldPop;
        }) ,
      ),
      FlatButton(
        child: Text('No'),
        onPressed: () => Navigator.of(c).popUntil((route) => route.isFirst),
      ),
    ],
  ),


 Navigator.popUntil(context, (Route<dynamic> route){
            bool shouldPop = false;
            if(route.settings.name == HomePage.routeName){
              shouldPop = true;
            }
            return shouldPop;
          });

Flutter - Disable/Override Back Button with WillPopScope

https://www.woolha.com/tutorials/flutter-disable-override-back-button-with-willpopscope